Example usage for org.springframework.web.servlet ModelAndView getModel

List of usage examples for org.springframework.web.servlet ModelAndView getModel

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView getModel.

Prototype

public Map<String, Object> getModel() 

Source Link

Document

Return the model map.

Usage

From source file:com.krawler.spring.iphone.iphoneController.java

public JSONObject getAllComboValueForProduct(HttpServletRequest request, HttpServletResponse response)
        throws ServiceException {
    JSONObject jobj = new JSONObject();
    JSONObject jobjOwner = new JSONObject();
    JSONObject jobjCategory = new JSONObject();
    ModelAndView model;
    try {/*ww w . ja v  a  2s . c o  m*/
        model = crmUserControllerObj.getOwner(request, response);
        jobjOwner = new JSONObject(model.getModel().get("model").toString());
        if (jobjOwner.has("success") && (jobjOwner.get("success").equals(true))) {
            jobj.append("owner", jobjOwner);
        }
        model = crmManagerControllerObj.getComboData(request, response);
        jobjCategory = new JSONObject(model.getModel().get("model").toString());
        if (jobjOwner.has("success") && (jobjOwner.get("success").equals(true))) {
            jobj.append("category", jobjCategory);
        }

    } catch (JSONException e) {
        logger.warn(e.getMessage(), e);
    } catch (ServletException e) {
        logger.warn(e.getMessage(), e);
    }

    return jobj;

}

From source file:com.krawler.spring.iphone.iphoneController.java

public JSONObject getAllComboValueForOpportunity(HttpServletRequest request, HttpServletResponse response)
        throws ServiceException {
    JSONObject jobj = new JSONObject();
    JSONObject jobjOwner = new JSONObject();
    JSONObject jobjCategory = new JSONObject();
    JSONObject jobjAccount = new JSONObject();
    JSONObject jobjStage = new JSONObject();
    ModelAndView model;
    try {//w w  w .j  a  va2s  .co  m
        String companyId = sessionHandlerImpl.getCompanyid(request);
        String comboName = request.getParameter("stage");
        model = crmUserControllerObj.getOwner(request, response);
        jobjOwner = new JSONObject(model.getModel().get("model").toString());
        if (jobjOwner.has("success") && (jobjOwner.get("success").equals(true))) {
            jobj.append("owner", jobjOwner);
        }
        model = crmManagerControllerObj.getComboData(request, response);
        jobjCategory = new JSONObject(model.getModel().get("model").toString());
        if (jobjOwner.has("success") && (jobjOwner.get("success").equals(true))) {
            jobj.append("LeadSource", jobjCategory);
        }
        model = crmOpportunityControllerObj.getAllAccounts(request, response);
        jobjAccount = new JSONObject(model.getModel().get("model").toString());
        if (jobjOwner.has("success") && (jobjOwner.get("success").equals(true))) {
            jobj.append("AccountName", jobjAccount);
        }
        jobjStage = getComboData(companyId, comboName);
        if (jobjOwner.has("success") && (jobjOwner.get("success").equals(true))) {
            jobj.append("Stage", jobjStage);
        }

    } catch (JSONException e) {
        logger.warn(e.getMessage(), e);
    } catch (ServletException e) {
        logger.warn(e.getMessage(), e);
    } catch (SessionExpiredException e) {
        logger.warn(e.getMessage(), e);
    }

    return jobj;

}

From source file:com.krawler.spring.iphone.iphoneController.java

private String getOpportunityForReports(HttpServletRequest request, HttpServletResponse response,
        int flagReport) throws ServiceException {
    String result = null;//  ww  w .  ja  v  a2 s .  c  om
    JSONArray jarr = new JSONArray();
    JSONObject commData = new JSONObject();

    try {
        //JSONObject temp = crmReports.getOpportunityForReports(session, request, flagReport);
        String timeFormatId = sessionHandlerImpl.getUserTimeFormat(request);
        String timeZoneDiff = sessionHandlerImpl.getTimeZoneDifference(request);
        ModelAndView model = null;
        switch (flagReport) {
        case 1:
            model = crmOpportunityReportControllerObj.closedOppReport(request, response);
            break;
        case 2:
            model = crmOpportunityReportControllerObj.oppByTypeReport(request, response);
            break;
        case 3:
            model = crmOpportunityReportControllerObj.oppProductReport(request, response);
            break;
        case 4:
            model = crmOpportunityReportControllerObj.stuckOppReport(request, response);
            break;
        }

        JSONObject temp = new JSONObject(model.getModel().get("model").toString());
        commData.put("totalCount", temp.getString("totalCount"));
        JSONArray jArray = temp.getJSONArray("coldata");
        for (int i = 0; i < jArray.length(); i++) {
            JSONObject j = jArray.getJSONObject(i);
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("primary", j.getString("oppname"));
            if (flagReport == 1) {
                tmpObj.put("desc", "closing date : " + authHandler.getDateFormatter(timeFormatId, timeZoneDiff)
                        .format(j.getLong("closingdate")));
                tmpObj.put("secondary", "Account name : " + j.getString("accountname"));
            } else if (flagReport == 2) {
                tmpObj.put("desc", "Stage : " + j.getString("oppstage"));
                tmpObj.put("secondary", "Type : " + j.getString("type"));
            } else if (flagReport == 3) {
                tmpObj.put("desc", "Stage : " + j.getString("oppstage"));
                tmpObj.put("secondary", "Product : " + j.getString("exportmultiproduct"));
            } else if (flagReport == 4) {
                tmpObj.put("secondary", "Stage : " + j.getString("oppstage"));
                tmpObj.put("desc", "Probability : " + j.getString("probability"));
            }
            jarr.put(tmpObj);
        }
        commData.put("data", jarr);
        commData.put("success", true);
        result = commData.toString();
    } catch (JSONException ex) {
        logger.warn(ex.getMessage(), ex);
        result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString()
                + ")\",\"data\":[]}";
        //        } catch (SessionExpiredException ex) {
        //            result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString() + ")\",\"data\":[]}";
    } catch (ServletException ex) {
        logger.warn(ex.getMessage(), ex);
        result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString()
                + ")\",\"data\":[]}";
    } catch (SessionExpiredException ex) {
        logger.warn(ex.getMessage(), ex);
        result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString()
                + ")\",\"data\":[]}";
    }
    return result;
}

From source file:org.guanxi.sp.engine.service.saml2.SAML2ProfileService.java

/** @see org.guanxi.sp.engine.service.generic.ProfileService#doProfile(javax.servlet.http.HttpServletRequest, String, String, org.guanxi.xal.saml2.metadata.GuardRoleDescriptorExtensions, String, org.guanxi.common.entity.EntityFarm) */
public ModelAndView doProfile(HttpServletRequest request, String guardID, String guardSessionID,
        GuardRoleDescriptorExtensions guardNativeMetadata, String entityID, EntityFarm farm)
        throws GuanxiException {
    ModelAndView mAndV = new ModelAndView();

    String relayState = guardSessionID.replaceAll("GUARD", "ENGINE");

    // Load the metadata for the IdP
    EntityManager manager = farm.getEntityManagerForID(entityID);
    if (manager == null) {
        logger.error("Could not find manager for IdP '" + entityID);
        throw new GuanxiException("Could not find manager for IdP " + entityID);
    }// www.j  a va 2 s. co m
    Metadata entityMetadata = manager.getMetadata(entityID);
    if (entityMetadata == null) {
        logger.error("Could not find manager for IdP " + entityID);
        throw new GuanxiException("Could not find metadata for IdP " + entityID);
    }
    EntityDescriptorType saml2Metadata = (EntityDescriptorType) entityMetadata.getPrivateData();

    String wbssoURL = null;
    String binding = null;
    EndpointType[] ssos = saml2Metadata.getIDPSSODescriptorArray(0).getSingleSignOnServiceArray();
    for (EndpointType sso : ssos) {
        if ((sso.getBinding().equalsIgnoreCase(SAML.SAML2_BINDING_HTTP_POST))
                || (sso.getBinding().equalsIgnoreCase(SAML.SAML2_BINDING_HTTP_REDIRECT))) {
            wbssoURL = sso.getLocation();
            if (sso.getBinding().equalsIgnoreCase(SAML.SAML2_BINDING_HTTP_POST))
                binding = SAML.SAML2_BINDING_HTTP_POST;
            else if (sso.getBinding().equalsIgnoreCase(SAML.SAML2_BINDING_HTTP_REDIRECT))
                binding = SAML.SAML2_BINDING_HTTP_REDIRECT;
            break;
        }
    }
    if (wbssoURL == null) {
        logger.error("IdP does not support WBSSO " + entityID);
        throw new GuanxiException("IdP does not support WBSSO " + entityID);
    }

    // Create an AuthnRequest
    AuthnRequestDocument authnRequestDoc = AuthnRequestDocument.Factory.newInstance();
    AuthnRequestType authnRequest = authnRequestDoc.addNewAuthnRequest();
    authnRequest.setID(Utils.createNCNameID());
    authnRequest.setVersion("2.0");
    authnRequest.setIssueInstant(Calendar.getInstance());
    Utils.zuluXmlObject(authnRequest, 0);
    NameIDType issuer = NameIDType.Factory.newInstance();
    issuer.setStringValue(guardID);
    authnRequest.setIssuer(issuer);
    authnRequest.setAssertionConsumerServiceURL(assertionConsumerServiceURL);
    authnRequest.setProtocolBinding(SAML.SAML2_BINDING_HTTP_POST);
    // Only if signed
    //authnRequest.setDestination("https://sgarbh.smo.uhi.ac.uk:8443/idp/profile/SAML2/POST/SSO");

    // Sort out the namespaces for saving the Response
    HashMap<String, String> namespaces = new HashMap<String, String>();
    namespaces.put(SAML.NS_SAML_20_PROTOCOL, SAML.NS_PREFIX_SAML_20_PROTOCOL);
    namespaces.put(SAML.NS_SAML_20_ASSERTION, SAML.NS_PREFIX_SAML_20_ASSERTION);

    XmlOptions xmlOptions = new XmlOptions();
    xmlOptions.setSavePrettyPrint();
    xmlOptions.setSavePrettyPrintIndent(2);
    xmlOptions.setUseDefaultNamespace();
    xmlOptions.setSaveAggressiveNamespaces();
    xmlOptions.setSaveSuggestedPrefixes(namespaces);
    xmlOptions.setSaveNamespacesFirst();

    // Get the config ready for signing
    SecUtilsConfig secUtilsConfig = new SecUtilsConfig();
    secUtilsConfig.setKeystoreFile(guardNativeMetadata.getKeystore());
    secUtilsConfig.setKeystorePass(guardNativeMetadata.getKeystorePassword());
    secUtilsConfig.setKeystoreType("JKS");
    secUtilsConfig.setPrivateKeyAlias(guardID);
    secUtilsConfig.setPrivateKeyPass(guardNativeMetadata.getKeystorePassword());
    secUtilsConfig.setCertificateAlias(guardID);

    // Break out to DOM land to get the SAML Response signed...
    /*
    Document signedDoc = null;
    try {
      // Need to use newDomNode to preserve namespace information
      signedDoc = SecUtils.getInstance().sign(secUtilsConfig, (Document)authnRequestDoc.newDomNode(xmlOptions), "");
      // ...and go back to XMLBeans land when it's ready
      authnRequestDoc = AuthnRequestDocument.Factory.parse(signedDoc);
    }
    catch(GuanxiException ge) {
      logger.error("Could not sign AuthnRequest", ge);
      mAndV.setViewName(errorView);
      mAndV.getModel().put(errorViewDisplayVar, messages.getMessage("engine.error.could.not.sign.message",
                                                            null, request.getLocale()));
      return mAndV;
    }
    catch(XmlException xe) {
      logger.error("Couldn't convert signed AuthnRequest back to XMLBeans", xe);
      mAndV.setViewName(errorView);
      mAndV.getModel().put(errorViewDisplayVar, messages.getMessage("engine.error.could.not.sign.message",
                                                            null, request.getLocale()));
      return mAndV;
    }
    */

    // Base 64 encode the AuthnRequest
    //String authnRequestB64 = Utils.base64(signedDoc);
    //String authnRequestB64 = Utils.base64((Document)authnRequestDoc.newDomNode(xmlOptions));

    // Do the profile quickstep
    String authnRequestForIdP = null;
    if (binding.equals(SAML.SAML2_BINDING_HTTP_REDIRECT)) {
        mAndV.setViewName(httpRedirectView);
        String deflatedRequest = Utils.deflate(authnRequestDoc.toString(),
                Utils.RFC1951_DEFAULT_COMPRESSION_LEVEL, Utils.RFC1951_NO_WRAP);
        authnRequestForIdP = Utils.base64(deflatedRequest.getBytes());
        authnRequestForIdP = authnRequestForIdP.replaceAll(System.getProperty("line.separator"), "");
        try {
            authnRequestForIdP = URLEncoder.encode(authnRequestForIdP, "UTF-8");
            relayState = URLEncoder.encode(relayState, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            logger.error("couldn't encode SAMLRequest");
            throw new GuanxiException("couldn't encode SAMLRequest: " + uee.getMessage());
        }
    } else if (binding.equals(SAML.SAML2_BINDING_HTTP_POST)) {
        mAndV.setViewName(httpPOSTView);
        authnRequestForIdP = Utils.base64(authnRequestDoc.toString().getBytes());
    }

    // Send the AuthnRequest to the IdP
    mAndV.getModel().put("SAMLRequest", authnRequestForIdP);
    mAndV.getModel().put("RelayState", relayState);
    mAndV.getModel().put("wbsso_endpoint", wbssoURL);
    return mAndV;
}

From source file:com.krawler.spring.iphone.iphoneController.java

public ModelAndView deskeraCRMMOB_V1(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    JSONObject jobj = new JSONObject();
    ModelAndView model;
    String result = "";
    try {//from  w w w.jav  a  2s . c o m
        int action = Integer.parseInt(request.getParameter("act"));
        int mode = Integer.parseInt(request.getParameter("mode"));
        if (action != 0) {
            try {
                if (StringUtil.isNullOrEmpty(sessionHandlerImpl.getUserid(request))) {
                    setUserSession(request, response);
                }
            } catch (SessionExpiredException ex) {
                logger.warn(
                        "Exception in iphoneController:deskeraCRMMOB_V1() - Session has not set. Need to create new session.");
                //                    logger.warn(ex.getMessage(), ex);
                setUserSession(request, response);
            }
        }

        switch (action) {
        case 0: // generate application id
            jobj = generateAppID(request, response);
            result = jobj.toString();
            break;
        case 1: // dashboard request
            switch (mode) {

            case 0: // get Modules Updates
                model = getCrmDashboardController().getAllUpdatesForWidget(request, response);
                result = model.getModel().get("model").toString();
                break;
            case 1: // get Reports
                result = getModuleReports(request);
                break;
            case 2:// view modules
                result = getModules(request);
                break;
            case 3:// view modules
                result = getModules(request);
                break;
            case 4:// get Messages

                String url = "/Common/MailIntegration/mailIntegrate.do?action=EmailUIAjax";
                RequestDispatcher dispatcher = request.getRequestDispatcher(url);
                dispatcher.forward(request, response);
                break;
            case 5:// get owner List
                   //jobj = crmDbcon.getOwner(request);
                   //result = jobj.toString();
                model = crmUserControllerObj.getOwner(request, response);
                jobj = new JSONObject(model.getModel().get("model").toString());
                result = jobj.toString();
                break;
            case 6:// get 1.Lead Status 2. Account Type 3. Indusrty
                   //String comboname = request.getParameter("comboname");
                model = crmManagerControllerObj.getComboData(request, response);
                jobj = new JSONObject(model.getModel().get("model").toString());
                result = jobj.toString();
                break;
            case 7:// get Account Name
                jobj = getAllAccounts(request, response);
                result = jobj.toString();
                break;
            case 8:// 1.get owner List 2.lead source 3.Stage 4.Account Name
                jobj = getAllComboValueForProduct(request, response);
                result = jobj.toString();
                break;
            case 9:// 1.get owner List 2.get category
                jobj = getAllComboValueForOpportunity(request, response);
                result = jobj.toString();
                break;
            case 10://sign out
                sessionHandlerImplObj.destroyUserSession(request, response);
                result = "{\"success\":\"true\"}";
                break;
            case 11://get user profile data
                result = getUserDetails(request);
                break;
            case 12:// get Campaign Data

                jobj = getCampaign(request, response);
                result = jobj.toString();
                break;
            case 13:// get Lead Data
                jobj = getLead(request, response);
                result = jobj.toString();
                break;
            case 14:// get Contact Data
                jobj = getContact(request, response);
                result = jobj.toString();
                break;
            case 16:// get Account Data
                jobj = getAccount(request, response);
                result = jobj.toString();
                break;
            case 18:// get Case Data
                jobj = getCase(request, response);
                result = jobj.toString();
                break;
            case 19:// get product Data
                jobj = getProduct(request, response);
                result = jobj.toString();
                break;
            case 20:// get Opportunity Data
                jobj = getopportunity(request, response);
                result = jobj.toString();
                break;
            }
            break;
        //<editor-fold defaultstate="collapsed" desc="Report Case Section. Click on the + sign on the left to edit the code.">
        case 2: // Get Reports
            switch (mode) {
            case 0://revenue by opp source &
                result = getSalesbyLeadsource(request, response);
                break;
            case 1: //  revenue by stage
                result = oppByStageReport(request, response);
                break;
            case 2:// Leads by Source
                result = getLeadbySource(request, response);
                break;
            case 3://Key Accounts
                result = getKeyAccounts(request);
                break;
            case 4://Cases by Status
                result = getCaseByStatus(request);
                break;
            case 5:// Converted leads
                result = getConvertedLeads(request, response);
                break;
            case 6://Sales by Source
                result = getSalesbysource(request, response);
                break;
            case 7:// Leads by Industry
                result = getLeadsByIndustry(request, response);
                break;
            case 8:// Closed Opportunities
                result = getOpportunityForReports(request, response, 1);
                break;
            case 9:// Opportunities By Type
                result = getOpportunityForReports(request, response, 2);
                break;
            case 10:// Opportunity Product Report
                result = getOpportunityForReports(request, response, 3);
                break;
            case 11:// Stuck Opportunities
                result = getOpportunityForReports(request, response, 4);
                break;
            case 12://Monthly Account
                result = getAccountPerMonth(request);
                break;
            case 13://Account Owners
                result = getAccountOwners(request);
                break;
            case 14:// Opporunity Source
                result = getOpporunitySource(request);
                break;
            case 15://HighPriorityActivities
                result = getHighPriorityActivities(request);
                break;
            case 16://Contacts with High Priority Cases
                result = getContactCases(request);
                break;
            case 17://ProductCases
                result = getProductCases(request);
                break;
            case 18://Account with High Priority Cases
                result = getAccountCases(request);
                break;
            case 19://Monthly Cases
                result = getMonthlyCases(request);
                break;
            case 20://Industry-Account Type Report
                result = getIndustryAccountType(request);
                break;
            case 21://Campaigns by Type
                result = getCampaignType(request);
                break;
            case 22://Completed Campaigns by Type
                result = getCompletedCampaign(request);
                break;
            case 23: //Qualified Leads
                result = getQualifiedLeads(request);
                break;
            case 24: //Accounts with Contacts
                result = getAccountWithContacts(request);
                break;
            case 25://Campaigns with Good Response
                result = getCampaignResponse(request);
                break;
            case 26: //Contacted Leads
                result = getContactedLeads(request);
                break;
            case 27: //Contacts by Lead Source
                result = getLeadContacts(request);
                break;
            case 28: //Accounts with Opportunities
                result = getAccountOpp(request);
                break;
            case 30://Newly Added Cases
                result = getNewlyAddedCase(request);
                break;
            case 31://Pending Cases
                result = getPendingCases(request);
                break;
            case 32://Escalated Cases
                result = getEscalatedCases(request);
                break;
            case 33: //Accounts with Cases
                result = getAccCases(request);
                break;
            case 34: //open Leads
                result = getOpenLeads(request);
                break;
            case 35: //open Leads
                result = getContactWithCase(request);
                break;
            case 36: //Converted Leads to Account
                result = getConvertedLeadsAccount(request);
                break;
            case 37: //Converted Leads to Opportunity
                result = getConvertedLeadsOpp(request);
                break;
            case 38: //Converted Leads to Contacts
                result = getConvertedLeadsContact(request);
                break;
            case 39://Targets by Owner
                result = getTargetOwner(request);
                break;
            case 40://Opp Pipelined
                result = getOpenOppPipelined(request);
                break;
            case 41://Lead pipeline
                result = getLeadPipelined(request);
                break;
            }
            break;
        case 3://update recordsde
            switch (mode) {
            case 0: //update user
                result = updateUser(request);
                break;
            case 1:
                result = sendMail(request, response);
                break;
            case 13:// insert Lead Data

                jobj = insertLead(request);
                result = jobj.toString();
                break;
            case 14:// insert Contact Data

                jobj = insertContact(request);
                result = jobj.toString();
                break;
            case 16:// insert Account Data

                jobj = insertAccount(request);
                result = jobj.toString();
                break;
            case 18:// insert Case Data

                jobj = insertCase(request);
                result = jobj.toString();
                break;
            case 19:// insert product Data

                jobj = insertProduct(request);
                result = jobj.toString();
                break;
            case 20:// insert Opportunity Data

                jobj = insertOpportunity(request);
                result = jobj.toString();
                break;
            }
            break;
        //<editor-fold defaultstate="collapsed" desc="chart Section. Click on the + sign on the left to edit the code.">
        case 4:// get Chart Data
            switch (mode) {
            case 1: //Leads by Source
                result = getChart(request, "Lead Source", "LeadsbySource");
                break;
            case 2: //Leads By Industry
                result = getChart(request, "Industry", "LeadsbyIndustry");
                break;
            case 3:// cases by status
                result = getChart(request, "Case Status", "CasesbyStatus");
                break;
            case 8:
                result = getChart(request, "Lead Source", "SourcesOfOpportunity");
                break;
            case 9:
                result = getHighPriorityActivityChart(request, "Related To");
                break;
            case 10:
                result = getChart(request, "Title", "ContactHighPriority");
                break;
            case 11:
                result = getProductHighPriorityChart(request);// no chart
                break;
            case 12:
                result = getAccountHighPriorityChart(request);// no chart
                break;
            case 14:
                result = getChart(request, "Industry", "IndustryAccountTypes");
                break;
            case 15:
                result = getChart(request, "Opportunity Type", "OpportunityByType");
                break;
            case 16:
                result = opportunityByProduct(request);
                break;
            case 17:
                result = accountsByOwner(request);
                break;
            case 18:
                result = getChart(request, "Opportunity Stage", "StuckOpportunities");
                break;
            case 20:
                result = closedOppPieChart(request);
                break;
            case 21:
                result = getChart(request, "Lead Source", "ConvertedLeads");
                break;
            case 25:
                result = getChart(request, "Lead Source", "OpportunitybySource");
                break;
            case 26:
                result = getChart(request, "Opportunity Stage", "OpportunitybyStage");
                break;
            case 28:
                result = getKeyAccountsPie(request);
                break;
            case 29:
                result = getChart(request, "Lead Source", "SalesbySource");
                break;
            case 35:
                result = getMonthlyChartPie(request, "MonthlyAccounts");
                break;
            case 42:
                result = getMonthlyChartPie(request, "MonthlyCases");
                break;
            case 44:
                result = getChart(request, "Campaign Type", "CampaignType");
                break;
            case 46:
                result = getChart(request, "Campaign Type", "CompletedCampaign");
                break;
            case 48:
                result = getChart(request, "Lead Source", "QualifiedLeads");
                break;
            case 50:
                result = getAccountContactPie(request);
                break;
            case 52:
                result = getChart(request, "Campaign Type", "CampaignResponse");
                break;
            case 54:
                result = getChart(request, "Lead Source", "ContactedLeads");
                break;
            case 56://  Contacts by Lead Source
                result = getChart(request, "Lead Source", "LeadSourceContacts");
                break;
            case 58:
                result = getAccountOpportunityPie(request);
                break;
            case 62:
                result = getChart(request, "Priority", "NewlyAddedCases");
                break;
            case 64:
                result = getChart(request, "Priority", "PendingCases");
                break;
            case 66:
                result = getChart(request, "Priority", "EscalatedCases");
                break;
            case 68:
                result = getAccountCasesPie(request);
                break;
            case 70:
                result = getOpenLeadsPie(request);
                break;
            case 72:
                result = getContactCasePie(request);
                break;
            case 74:
                result = getChart(request, "Lead Source", "ConvertedLeadAccount");
                break;
            case 76:
                result = getChart(request, "Lead Source", "ConvertedLeadOpp");
                break;
            case 78:
                result = getChart(request, "Lead Source", "ConvertedLeadContact");
                break;
            case 80:
                result = getTargetOwnerPie(request);
                break;
            case 84:
                result = getChart(request, "Opportunity Stage", "OpportunityPipeline");
                break;
            case 86:
                result = getChart(request, "Lead Status", "LeadPipeline");
                break;
            }
            break;
        }
    } catch (JSONException ex) {
        logger.warn(ex.getMessage(), ex);
        result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString()
                + ")\",\"data\":[]}";
    } catch (ServiceException ex) {
        logger.warn(ex.getMessage(), ex);
        result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString()
                + ")\",\"data\":[]}";
    } catch (SessionExpiredException ex) {
        logger.warn(ex.getMessage(), ex);
        result = "{\"success\":\"false\",\"error\":\"Error occured while retreiving data(" + ex.toString()
                + ")\",\"data\":[]}";
    }
    return new ModelAndView("jsonView-ex", "model", result);
}

From source file:com.erudika.scoold.utils.ScooldRequestInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {

    if (modelAndView == null || StringUtils.startsWith(modelAndView.getViewName(), "redirect:")) {
        return; // skip if redirect
    }/*from w w w  .j  a v  a 2s  .c  om*/

    /*============================*
     * COMMON MODEL FOR ALL PAGES *
     *============================*/

    // Misc
    modelAndView.addObject("HOMEPAGE", HOMEPAGE);
    modelAndView.addObject("APPNAME", Config.APP_NAME);
    modelAndView.addObject("CDN_URL", CDN_URL);
    modelAndView.addObject("DESCRIPTION", Config.getConfigParam("meta_description", ""));
    modelAndView.addObject("KEYWORDS", Config.getConfigParam("meta_keywords", ""));
    modelAndView.addObject("IN_PRODUCTION", Config.IN_PRODUCTION);
    modelAndView.addObject("IN_DEVELOPMENT", !Config.IN_PRODUCTION);
    modelAndView.addObject("MAX_ITEMS_PER_PAGE", Config.MAX_ITEMS_PER_PAGE);
    modelAndView.addObject("SESSION_TIMEOUT_SEC", Config.SESSION_TIMEOUT_SEC);
    modelAndView.addObject("TOKEN_PREFIX", TOKEN_PREFIX);
    modelAndView.addObject("FB_APP_ID", Config.FB_APP_ID);
    modelAndView.addObject("GMAPS_API_KEY", Config.getConfigParam("gmaps_api_key", ""));
    modelAndView.addObject("GOOGLE_CLIENT_ID", Config.getConfigParam("google_client_id", ""));
    modelAndView.addObject("GOOGLE_ANALYTICS_ID", Config.getConfigParam("google_analytics_id", ""));
    modelAndView.addObject("includeHighlightJS", Config.getConfigBoolean("code_highlighting_enabled", true));
    modelAndView.addObject("isAjaxRequest", utils.isAjaxRequest(request));
    modelAndView.addObject("reportTypes", ReportType.values());
    modelAndView.addObject("returnto", StringUtils.removeStart(request.getRequestURI(), CONTEXT_PATH));
    // Configurable constants
    modelAndView.addObject("MAX_TEXT_LENGTH", MAX_TEXT_LENGTH);
    modelAndView.addObject("MAX_TAGS_PER_POST", MAX_TAGS_PER_POST);
    modelAndView.addObject("MAX_REPLIES_PER_POST", MAX_REPLIES_PER_POST);
    modelAndView.addObject("MAX_FAV_TAGS", MAX_FAV_TAGS);
    modelAndView.addObject("ANSWER_VOTEUP_REWARD_AUTHOR", ANSWER_VOTEUP_REWARD_AUTHOR);
    modelAndView.addObject("QUESTION_VOTEUP_REWARD_AUTHOR", QUESTION_VOTEUP_REWARD_AUTHOR);
    modelAndView.addObject("VOTEUP_REWARD_AUTHOR", VOTEUP_REWARD_AUTHOR);
    modelAndView.addObject("ANSWER_APPROVE_REWARD_AUTHOR", ANSWER_APPROVE_REWARD_AUTHOR);
    modelAndView.addObject("ANSWER_APPROVE_REWARD_VOTER", ANSWER_APPROVE_REWARD_VOTER);
    modelAndView.addObject("POST_VOTEDOWN_PENALTY_AUTHOR", POST_VOTEDOWN_PENALTY_AUTHOR);
    modelAndView.addObject("POST_VOTEDOWN_PENALTY_VOTER", POST_VOTEDOWN_PENALTY_VOTER);
    modelAndView.addObject("VOTER_IFHAS", VOTER_IFHAS);
    modelAndView.addObject("COMMENTATOR_IFHAS", COMMENTATOR_IFHAS);
    modelAndView.addObject("CRITIC_IFHAS", CRITIC_IFHAS);
    modelAndView.addObject("SUPPORTER_IFHAS", SUPPORTER_IFHAS);
    modelAndView.addObject("GOODQUESTION_IFHAS", GOODQUESTION_IFHAS);
    modelAndView.addObject("GOODANSWER_IFHAS", GOODANSWER_IFHAS);
    modelAndView.addObject("ENTHUSIAST_IFHAS", ENTHUSIAST_IFHAS);
    modelAndView.addObject("FRESHMAN_IFHAS", FRESHMAN_IFHAS);
    modelAndView.addObject("SCHOLAR_IFHAS", SCHOLAR_IFHAS);
    modelAndView.addObject("TEACHER_IFHAS", TEACHER_IFHAS);
    modelAndView.addObject("PROFESSOR_IFHAS", PROFESSOR_IFHAS);
    modelAndView.addObject("GEEK_IFHAS", GEEK_IFHAS);
    // Cookies
    modelAndView.addObject("localeCookieName", LOCALE_COOKIE);
    modelAndView.addObject("csrfCookieName", CSRF_COOKIE);
    // Paths
    modelAndView.addObject("imageslink", IMAGESLINK); // do not add context path prefix!
    modelAndView.addObject("scriptslink", SCRIPTSLINK); // do not add context path prefix!
    modelAndView.addObject("styleslink", STYLESLINK); // do not add context path prefix!
    modelAndView.addObject("peoplelink", CONTEXT_PATH + PEOPLELINK);
    modelAndView.addObject("profilelink", CONTEXT_PATH + PROFILELINK);
    modelAndView.addObject("searchlink", CONTEXT_PATH + SEARCHLINK);
    modelAndView.addObject("signinlink", CONTEXT_PATH + SIGNINLINK);
    modelAndView.addObject("signoutlink", CONTEXT_PATH + SIGNOUTLINK);
    modelAndView.addObject("aboutlink", CONTEXT_PATH + ABOUTLINK);
    modelAndView.addObject("privacylink", CONTEXT_PATH + PRIVACYLINK);
    modelAndView.addObject("termslink", CONTEXT_PATH + TERMSLINK);
    modelAndView.addObject("tagslink", CONTEXT_PATH + TAGSLINK);
    modelAndView.addObject("settingslink", CONTEXT_PATH + SETTINGSLINK);
    modelAndView.addObject("translatelink", CONTEXT_PATH + TRANSLATELINK);
    modelAndView.addObject("reportslink", CONTEXT_PATH + REPORTSLINK);
    modelAndView.addObject("adminlink", CONTEXT_PATH + ADMINLINK);
    modelAndView.addObject("votedownlink", CONTEXT_PATH + VOTEDOWNLINK);
    modelAndView.addObject("voteuplink", CONTEXT_PATH + VOTEUPLINK);
    modelAndView.addObject("questionlink", CONTEXT_PATH + QUESTIONLINK);
    modelAndView.addObject("questionslink", CONTEXT_PATH + QUESTIONSLINK);
    modelAndView.addObject("commentlink", CONTEXT_PATH + COMMENTLINK);
    modelAndView.addObject("postlink", CONTEXT_PATH + POSTLINK);
    modelAndView.addObject("revisionslink", CONTEXT_PATH + REVISIONSLINK);
    modelAndView.addObject("feedbacklink", CONTEXT_PATH + FEEDBACKLINK);
    modelAndView.addObject("languageslink", CONTEXT_PATH + LANGUAGESLINK);
    // Visual customization
    modelAndView.addObject("navbarFixedClass",
            Config.getConfigBoolean("fixed_nav", false) ? "navbar-fixed" : "none");
    modelAndView.addObject("showBranding", Config.getConfigBoolean("show_branding", true));
    modelAndView.addObject("logoUrl", Config.getConfigParam("logo_url", IMAGESLINK + "/logo.svg"));
    modelAndView.addObject("logoWidth", Config.getConfigInt("logo_width", 90));
    modelAndView.addObject("stylesheetUrl", Config.getConfigParam("stylesheet_url", STYLESLINK + "/style.css"));
    // Auth & Badges
    Profile authUser = (Profile) request.getAttribute(AUTH_USER_ATTRIBUTE);
    modelAndView.addObject("infoStripMsg",
            authUser == null ? Config.getConfigParam("welcome_message", "") : "");
    modelAndView.addObject("authenticated", authUser != null);
    modelAndView.addObject("canComment", utils.canComment(authUser, request));
    modelAndView.addObject("isMod", utils.isMod(authUser));
    modelAndView.addObject("isAdmin", utils.isAdmin(authUser));
    modelAndView.addObject("utils", Utils.getInstance());
    modelAndView.addObject("scooldUtils", utils);
    modelAndView.addObject("authUser", authUser);
    modelAndView.addObject("badgelist", utils.checkForBadges(authUser, request));
    modelAndView.addObject("request", request);
    // Spaces
    modelAndView.addObject("currentSpace",
            utils.getValidSpaceId(authUser, getCookieValue(request, SPACE_COOKIE)));
    // Language
    Locale currentLocale = utils.getCurrentLocale(utils.getLanguageCode(request), request);
    modelAndView.addObject("currentLocale", currentLocale);
    modelAndView.addObject("lang", utils.getLang(currentLocale));
    modelAndView.addObject("langDirection", utils.isLanguageRTL(currentLocale.getLanguage()) ? "RTL" : "LTR");
    // Pagination
    // check for AJAX pagination requests
    if (utils.isAjaxRequest(request) && (utils.param(request, "page") || utils.param(request, "page1")
            || utils.param(request, "page2"))) {
        modelAndView.setViewName("pagination"); // switch to page fragment view
    }
    // CSP, HSTS, etc, headers. See https://securityheaders.com
    utils.setSecurityHeaders(request, response);

    // default metadata for social meta tags
    if (!modelAndView.getModel().containsKey("title")) {
        modelAndView.addObject("title", Config.APP_NAME);
    }
    if (!modelAndView.getModel().containsKey("description")) {
        modelAndView.addObject("description", Config.getConfigParam("meta_description", ""));
    }
    if (!modelAndView.getModel().containsKey("ogimage")) {
        modelAndView.addObject("ogimage", IMAGESLINK + "/logowhite.png");
    }
}

From source file:org.guanxi.idp.service.shibboleth.SSO.java

@SuppressWarnings("unchecked")
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    ModelAndView mAndV = new ModelAndView();

    // Load up the config file
    IdpDocument.Idp idpConfig = (IdpDocument.Idp) getServletContext()
            .getAttribute(Guanxi.CONTEXT_ATTR_IDP_CONFIG);

    /* The cookie interceptor should populate this if it finds a principal. The chain also
     * includes the cookie handlers so that will include embedded mode authentication.
     *///from   w  w w. ja  v  a 2 s .co  m
    GuanxiPrincipal principal = (GuanxiPrincipal) request.getAttribute(Guanxi.REQUEST_ATTR_IDP_PRINCIPAL);

    // Need these for the Response
    String issuer = null;
    String nameQualifier = null;
    String nameQualifierFormat = null;
    // Need this for signing the Response
    Creds credsConfig = null;

    /* Now load the appropriate identity and creds from the config file.
     * We'll either use the default or the ones that the particular SP
     * needs to be sent.
     */
    String spID = null;
    ServiceProvider[] spList = idpConfig.getServiceProviderArray();
    for (int c = 0; c < spList.length; c++) {
        if (spList[c].getName().equals(request.getParameter(Shibboleth.PROVIDER_ID))) {
            spID = request.getParameter(Shibboleth.PROVIDER_ID);
        }
    }
    if (spID == null) {
        // No specific requirement for this SP so use the default identity and creds
        spID = defaultSPEntry;
    }

    // Now we've sorted the SP id to use, load the identity and creds
    for (int c = 0; c < spList.length; c++) {
        if (spList[c].getName().equals(spID)) {
            String identityToUse = spList[c].getIdentity();
            String credsToUse = spList[c].getCreds();

            // We've found the <service-provider> node so look for the corresponding <identity> node
            org.guanxi.xal.idp.Identity[] ids = idpConfig.getIdentityArray();
            for (int cc = 0; cc < ids.length; cc++) {
                if (ids[cc].getName().equals(identityToUse)) {
                    issuer = ids[cc].getIssuer();
                    nameQualifier = ids[cc].getNameQualifier();
                    nameQualifierFormat = ids[cc].getFormat();
                }
            }

            // Look for the corresponding <creds> node
            org.guanxi.xal.idp.Creds[] creds = idpConfig.getCredsArray();
            for (int ccc = 0; ccc < creds.length; ccc++) {
                if (creds[ccc].getName().equals(credsToUse)) {
                    credsConfig = creds[ccc];
                }
            }
        }
    }

    // Associate the principal with the issuer to use...
    principal.addIssuer(request.getParameter(Shibboleth.PROVIDER_ID), issuer);
    // ...and the SAML signing credentials
    principal.addSigningCreds(request.getParameter(Shibboleth.PROVIDER_ID), credsConfig);

    // Sort out the namespaces for saving the Response
    HashMap<String, String> namespaces = new HashMap<String, String>();
    namespaces.put(Shibboleth.NS_SAML_10_PROTOCOL, Shibboleth.NS_PREFIX_SAML_10_PROTOCOL);
    namespaces.put(Shibboleth.NS_SAML_10_ASSERTION, Shibboleth.NS_PREFIX_SAML_10_ASSERTION);
    XmlOptions xmlOptions = new XmlOptions();
    xmlOptions.setSavePrettyPrint();
    xmlOptions.setSavePrettyPrintIndent(2);
    xmlOptions.setUseDefaultNamespace();
    xmlOptions.setSaveAggressiveNamespaces();
    xmlOptions.setSaveSuggestedPrefixes(namespaces);
    xmlOptions.setSaveNamespacesFirst();

    /* No need to set the InResponseTo attribute as SAML1.1 core states that if the
     * corresponding RequestID attribute of the request can't be determined then we
     * shouldn't include InResponseTo. Shibboleth makes a request, though not through
     * SAML, so RequestID in the initial GET request doesn't exist.
     */
    ResponseDocument samlResponseDoc = ResponseDocument.Factory.newInstance(xmlOptions);
    ResponseType samlResponse = samlResponseDoc.addNewResponse();
    samlResponse.setResponseID(Utils.createNCNameID());
    samlResponse.setMajorVersion(new BigInteger("1"));
    samlResponse.setMinorVersion(new BigInteger("1"));
    samlResponse.setIssueInstant(Calendar.getInstance());
    samlResponse.setRecipient(request.getParameter(Shibboleth.SHIRE));
    Utils.zuluXmlObject(samlResponse, 0);

    // Get a Status ready
    StatusDocument statusDoc = StatusDocument.Factory.newInstance();
    StatusType status = statusDoc.addNewStatus();
    StatusCodeType topLevelStatusCode = status.addNewStatusCode();
    topLevelStatusCode.setValue(new QName("", Shibboleth.SAMLP_SUCCESS));

    // Add the Status to the Response
    samlResponse.setStatus(status);

    // Get an Assertion ready
    AssertionDocument assertionDoc = AssertionDocument.Factory.newInstance();
    AssertionType assertion = assertionDoc.addNewAssertion();
    assertion.setAssertionID(Utils.createNCNameID());
    assertion.setMajorVersion(new BigInteger("1"));
    assertion.setMinorVersion(new BigInteger("1"));
    assertion.setIssuer(issuer);
    assertion.setIssueInstant(Calendar.getInstance());
    Utils.zuluXmlObject(assertion, 0);

    // Conditions for the Assertion
    ConditionsDocument conditionsDoc = ConditionsDocument.Factory.newInstance();
    ConditionsType conditions = conditionsDoc.addNewConditions();
    conditions.setNotBefore(Calendar.getInstance());
    conditions.setNotOnOrAfter(Calendar.getInstance());
    Utils.zuluXmlObject(conditions, 5);

    // By attaching an Audience, we're saying that only the current SP can use this Assertion
    AudienceRestrictionConditionDocument audienceDoc = AudienceRestrictionConditionDocument.Factory
            .newInstance();
    AudienceRestrictionConditionType audience = audienceDoc.addNewAudienceRestrictionCondition();
    audience.setAudienceArray(new String[] { request.getParameter(Shibboleth.PROVIDER_ID) });

    // Add an Audience to the Conditions
    conditions.setAudienceRestrictionConditionArray(new AudienceRestrictionConditionType[] { audience });

    // Add Conditions to the Assertion
    assertion.setConditions(conditions);

    // Get an AuthenticationStatement ready
    AuthenticationStatementDocument authStatementDoc = AuthenticationStatementDocument.Factory.newInstance();
    AuthenticationStatementType authStatement = authStatementDoc.addNewAuthenticationStatement();
    authStatement.setAuthenticationInstant(Calendar.getInstance());
    authStatement.setAuthenticationMethod(SAML.URN_AUTH_METHOD_PASSWORD);
    Utils.zuluXmlObject(authStatement, 0);

    // Get a Subject ready
    SubjectDocument subjectDoc = SubjectDocument.Factory.newInstance();
    SubjectType subject = subjectDoc.addNewSubject();

    // Build the NameIdentifier
    NameIdentifierDocument nameIDDoc = NameIdentifierDocument.Factory.newInstance();
    NameIdentifierType nameID = nameIDDoc.addNewNameIdentifier();
    nameID.setNameQualifier(nameQualifier);
    nameID.setFormat(nameQualifierFormat);
    nameID.setStringValue(principal.getUniqueId());

    // Add the NameIdentifier to the Subject
    subject.setNameIdentifier(nameID);

    // Get a SubjectConfirmation ready
    SubjectConfirmationDocument subjectConfirmationDoc = SubjectConfirmationDocument.Factory.newInstance();
    SubjectConfirmationType subjectConfirmation = subjectConfirmationDoc.addNewSubjectConfirmation();
    subjectConfirmation.addConfirmationMethod(SAML.URN_CONFIRMATION_METHOD_BEARER);

    // Add the SubjectConfirmation to the Subject
    subject.setSubjectConfirmation(subjectConfirmation);

    // Add the Subject to the AuthenticationStatement
    authStatement.setSubject(subject);

    // Add the Conditions to the Assertion
    assertion.setConditions(conditions);

    // Add the AuthenticationStatement to the Assertion
    assertion.setAuthenticationStatementArray(new AuthenticationStatementType[] { authStatement });

    // Add the Assertion to the Response
    samlResponse.setAssertionArray(new AssertionType[] { assertion });

    // Get the config ready for signing
    SecUtilsConfig secUtilsConfig = new SecUtilsConfig();
    secUtilsConfig.setKeystoreFile(credsConfig.getKeystoreFile());
    secUtilsConfig.setKeystorePass(credsConfig.getKeystorePassword());
    secUtilsConfig.setKeystoreType(credsConfig.getKeystoreType());
    secUtilsConfig.setPrivateKeyAlias(credsConfig.getPrivateKeyAlias());
    secUtilsConfig.setPrivateKeyPass(credsConfig.getPrivateKeyPassword());
    secUtilsConfig.setCertificateAlias(credsConfig.getCertificateAlias());
    secUtilsConfig.setKeyType(credsConfig.getKeyType());

    // Break out to DOM land to get the SAML Response signed...
    Document signedDoc = null;
    try {
        // Need to use newDomNode to preserve namespace information
        signedDoc = SecUtils.getInstance().sign(secUtilsConfig,
                (Document) samlResponseDoc.newDomNode(xmlOptions), "");
    } catch (GuanxiException ge) {
        logger.error("Couldn't sign the Response", ge);
        mAndV.setViewName(errorView);
        return mAndV;
    }

    try {
        // ...and go back to XMLBeans land when it's ready
        samlResponseDoc = ResponseDocument.Factory.parse(signedDoc);
    } catch (XmlException xe) {
        logger.error("Couldn't get a signed Response", xe);
        mAndV.setViewName(errorView);
        return mAndV;
    }

    // Base 64 encode the SAML Response
    String samlResponseB64 = Utils.base64(signedDoc);

    // Bung the encoded Response in the HTML form
    request.setAttribute("saml_response", samlResponseB64);

    // Debug syphoning?
    if (idpConfig.getDebug() != null) {
        if (idpConfig.getDebug().getSypthonAttributeAssertions() != null) {
            if (idpConfig.getDebug().getSypthonAttributeAssertions().equals("yes")) {
                logger.info("=======================================================");
                logger.info("IdP response to Shire with providerId "
                        + request.getParameter(Shibboleth.PROVIDER_ID));
                logger.info("");
                StringWriter sw = new StringWriter();
                samlResponseDoc.save(sw, xmlOptions);
                logger.info(sw.toString());
                sw.close();
                logger.info("");
                logger.info("=======================================================");
            }
        }
    }

    for (IdPFilter filter : filters) {
        filter.filter(principal, request.getParameter(Shibboleth.PROVIDER_ID), samlResponseDoc);
    }

    // Send the Response to the SP
    mAndV.setViewName(shibView);
    mAndV.getModel().put(Shibboleth.SHIRE, request.getParameter(Shibboleth.SHIRE));
    return mAndV;
}

From source file:org.capelin.mvc.controller.CatalogRecordController.java

public ModelAndView externalLinkSearch(HttpServletRequest request, HttpServletResponse response) {
    String docType = WebUtils.findParameterValue(request, REQUEST_EXT_DOC_TYPE);
    String term = WebUtils.findParameterValue(request, REQUEST_LINK_TERM);
    String value = WebUtils.findParameterValue(request, REQUEST_LINK_VALUE);
    String matchAll = WebUtils.findParameterValue(request, REQUEST_EXT_MATCH_ALL);
    if (null == value)
        return defaultError(null, null);
    term = (null == term) ? "" : term;
    boolean match = (null == matchAll) ? false : true;
    HttpSession session = request.getSession();
    BasicSearchObject sfo = getBasicSearchObject();
    sfo.setTerm(term);//w  w  w.  j av  a2  s.c  o  m
    sfo.setValue(value);
    sfo.setMatchAll(match);
    sfo.setDocumentType(docType);
    ModelAndView mav = search(session, sfo, 1);
    Integer i = (Integer) mav.getModel().get(REQUEST_RESULT_TOTAL);
    if (i <= 0) {
        sfo.setValue(WebViewUtils.getAllRequredTermValue(value, WebViewUtils.PLUS));
        sfo.setLuceneQuery(null);
        mav = search(session, sfo, 1);
    }
    return mav;
}

From source file:org.cloudifysource.rest.interceptors.ApiVersionValidationAndRestResponseBuilderInterceptor.java

/**
 * Filters the modelAndView object and retrieves the actual object returned by the controller.
 * This implementation assumes the model consists of just one returned object and a BindingResult.
 * If the model is empty, the supported return types are String (the view name) or void.
 *//*from   w  w  w . j a  v  a 2 s . c  om*/
private Object filterModel(final ModelAndView modelAndView, final Object handler) throws RestErrorException {

    Object methodReturnObject = null;
    Map<String, Object> model = modelAndView.getModel();

    if (MapUtils.isNotEmpty(model)) {
        // the model is not empty. The return value is the first value that is not a BindingResult
        for (Map.Entry<String, Object> entry : model.entrySet()) {
            Object value = entry.getValue();
            if (!(value instanceof BindingResult)) {
                methodReturnObject = value;
                break;
            }
        }
        if (methodReturnObject == null) {
            logger.warning("return object not found in model: " + model.toString());
            throw new RestErrorException("return object not found in model: " + model.toString());
        }
    } else {
        // the model is empty, this means the return type is String or void
        if (handler instanceof HandlerMethod) {
            Class<?> returnType = ((HandlerMethod) handler).getMethod().getReturnType();
            if (returnType == Void.TYPE) {
                methodReturnObject = null;
            } else if (returnType == String.class) {
                String viewName = modelAndView.getViewName();
                methodReturnObject = viewName;
            } else {
                logger.warning("return type not supported: " + returnType);
                throw new RestErrorException("return type not supported: " + returnType);
            }
        } else {
            logger.warning("handler object is not a HandlerMethod: " + handler);
            throw new RestErrorException("handler object is not a HandlerMethod: " + handler);
        }
    }

    return methodReturnObject;
}