Search in sources :

Example 16 with JsonGenerationException

use of org.codehaus.jackson.JsonGenerationException in project spring-data-document-examples by spring-projects.

the class CouchDbMappingJacksonHttpMessageConverter method writeInternal.

@Override
protected void writeInternal(Object o, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
    JsonEncoding encoding = getEncoding(outputMessage.getHeaders().getContentType());
    JsonGenerator jsonGenerator = this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);
    try {
        if (this.prefixJson) {
            jsonGenerator.writeRaw("{} && ");
        }
        this.objectMapper.writeValue(jsonGenerator, o);
    } catch (JsonGenerationException ex) {
        throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
    }
}
Also used : HttpMessageNotWritableException(org.springframework.http.converter.HttpMessageNotWritableException) JsonEncoding(org.codehaus.jackson.JsonEncoding) JsonGenerator(org.codehaus.jackson.JsonGenerator) JsonGenerationException(org.codehaus.jackson.JsonGenerationException)

Example 17 with JsonGenerationException

use of org.codehaus.jackson.JsonGenerationException in project spring-data-document-examples by spring-projects.

the class CouchDbMappingJacksonHttpMessageConverter method writeInternal.

@Override
protected void writeInternal(Object o, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
    JsonEncoding encoding = getEncoding(outputMessage.getHeaders().getContentType());
    JsonGenerator jsonGenerator = this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);
    try {
        if (this.prefixJson) {
            jsonGenerator.writeRaw("{} && ");
        }
        this.objectMapper.writeValue(jsonGenerator, o);
    } catch (JsonGenerationException ex) {
        throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
    }
}
Also used : HttpMessageNotWritableException(org.springframework.http.converter.HttpMessageNotWritableException) JsonEncoding(org.codehaus.jackson.JsonEncoding) JsonGenerator(org.codehaus.jackson.JsonGenerator) JsonGenerationException(org.codehaus.jackson.JsonGenerationException)

Example 18 with JsonGenerationException

use of org.codehaus.jackson.JsonGenerationException in project portal by ixinportal.

the class BindCertWebController method bindPage.

@RequestMapping("/bindCertPage")
public String bindPage(@RequestParam(value = "certSn", required = true) String certSn, HttpSession session, Model uiModel) throws UserInfoServiceException {
    // 是否登录
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        return "redirect:/userInfoWeb/denglu.html";
    }
    // 返回所有信任源所有
    List<String> allIssUerDn = new ArrayList<String>();
    allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
    try {
        uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
    } catch (JsonGenerationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    UserCert userCert = null;
    userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert)
        throw new UserInfoServiceException("未找到对应的证书信息");
    // DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    UserCertPojo ucp = new UserCertPojo(userCert, userCert.getCertStartTime().getTime() + "", userCert.getCertEndTime().getTime() + "");
    CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByPrimaryKey", userCert.getCertBuf());
    uiModel.addAttribute("userCert", ucp);
    uiModel.addAttribute("certBase64", certBuf.getCertBuf().replaceAll("\n", ""));
    return "ixinweb/bangding";
}
Also used : UserCertPojo(com.itrus.portal.utils.UserCertPojo) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) Enterprise(com.itrus.portal.db.Enterprise) ArrayList(java.util.ArrayList) CertBuf(com.itrus.portal.db.CertBuf) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with JsonGenerationException

use of org.codehaus.jackson.JsonGenerationException in project portal by ixinportal.

the class RegisterController method register.

@RequestMapping(value = "/s/{name}")
public String register(@PathVariable("name") String name, @RequestParam(value = "login", required = false) String login, HttpSession session, Model uiModel) {
    ProductExample productExample = new ProductExample();
    ProductExample.Criteria pe = productExample.createCriteria();
    pe.andProNameEqualTo(name);
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByExample", productExample);
    // return
    // "forward:/userInfoWeb/zhuce.html?projectId="+product.getProject()+"&productId="+product.getId();
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", product.getProject());
    uiModel.addAttribute("projectId", product.getProject());
    uiModel.addAttribute("productId", product.getId());
    uiModel.addAttribute("productName", product.getName());
    uiModel.addAttribute("projectName", project.getName());
    if (StringUtils.isNotBlank(login) && login.equals("1")) {
        List<String> allIssUerDn = new ArrayList<String>();
        allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
        try {
            uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
            // 返回随机数
            String random = UniqueIDUtils.genUUID();
            uiModel.addAttribute("random", random);
            session.setAttribute("webrandom", random);
        } catch (JsonGenerationException e) {
            e.printStackTrace();
        } catch (JsonMappingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "ixinweb/denglu2";
    }
    if (null != product.getIsBan() && product.getIsBan() == true) {
        EnterpriseQqExample enterprise1 = new EnterpriseQqExample();
        EnterpriseQqExample.Criteria qqEx = enterprise1.createCriteria();
        qqEx.andProjectIdEqualTo(product.getProject());
        EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterprise1);
        if (enterpriseqq != null && enterpriseqq.getEnterpriseQq() != null) {
            uiModel.addAttribute("enterpriseqq", enterpriseqq.getEnterpriseQqLinks());
        }
        // 产品已经下架
        return "ixinweb/chanpinxiajia";
    }
    return "ixinweb/zhuce";
}
Also used : ProductExample(com.itrus.portal.db.ProductExample) Product(com.itrus.portal.db.Product) IOException(java.io.IOException) Project(com.itrus.portal.db.Project) EnterpriseQq(com.itrus.portal.db.EnterpriseQq) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) EnterpriseQqExample(com.itrus.portal.db.EnterpriseQqExample) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with JsonGenerationException

use of org.codehaus.jackson.JsonGenerationException in project portal by ixinportal.

the class SecurityServiceWebController method securityCenter.

// 选出当前用户当前企业的所有证书和证书所绑定的用户信息
@RequestMapping("/securityCenter")
public String securityCenter(HttpSession session, Model uiModel) {
    UserInfo userInfos = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == userInfos || null == enterprise) {
        // 登录状态失效,跳转到注册页面
        return "redirect:/userInfoWeb/denglu.html";
    }
    Map param = new HashMap();
    param.put("userinfoid", userInfos.getId());
    param.put("enterpriseid", enterprise.getId());
    List<Map<String, Object>> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoAndEnterprise", param);
    if (null != userCertList && !userCertList.isEmpty()) {
        for (int i = 0; i < userCertList.size(); i++) {
            if (null != userCertList.get(i).get("bill_status") && (userCertList.get(i).get("bill_status").equals(ComNames.BILL_STATUS_8) || userCertList.get(i).get("bill_status").equals(ComNames.BILL_STATUS_7) || userCertList.get(i).get("bill_status").equals(ComNames.BILL_STATUS_6)) && userCertList.get(i).containsKey("renewBillId")) {
                // 状态为已完成的订单并且订单包含旧证书id
                Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", userCertList.get(i).get("renewBillId"));
                if (null != bill.getOldUserCert()) {
                    UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", bill.getOldUserCert());
                    userCertList.get(i).put("oldCertSn", oldUserCert.getCertSn());
                }
            }
        }
    }
    try {
        String usercertsString = jsonTool.writeValueAsString(userCertList);
        uiModel.addAttribute("usercerts", usercertsString);
        List<String> allIssUerDn = new ArrayList<String>();
        allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
        uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
    } catch (JsonGenerationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return "ixinweb/anquanfuwu";
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) Enterprise(com.itrus.portal.db.Enterprise) Bill(com.itrus.portal.db.Bill) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) HashMap(java.util.HashMap) Map(java.util.Map) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

JsonGenerationException (org.codehaus.jackson.JsonGenerationException)34 IOException (java.io.IOException)30 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)27 Response (javax.ws.rs.core.Response)13 GET (javax.ws.rs.GET)10 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 ArrayList (java.util.ArrayList)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 JsonGenerator (org.codehaus.jackson.JsonGenerator)7 StringWriter (java.io.StringWriter)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Enterprise (com.itrus.portal.db.Enterprise)4 UserCert (com.itrus.portal.db.UserCert)4 UserInfo (com.itrus.portal.db.UserInfo)4 HttpSession (javax.servlet.http.HttpSession)4 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)4 Bill (com.itrus.portal.db.Bill)3