use of org.codehaus.jackson.JsonGenerationException in project portal by ixinportal.
the class HomeController 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();
uiModel.addAttribute("projectId", product.getProject());
uiModel.addAttribute("productId", product.getId());
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) {
// 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/denglu2";
}
if (null != product.getIsBan() && product.getIsBan() == true) {
EnterpriseQqExample enterprise = new EnterpriseQqExample();
EnterpriseQqExample.Criteria qqEx = enterprise.createCriteria();
qqEx.andProjectIdEqualTo(product.getProject());
EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterprise);
uiModel.addAttribute("enterpriseqq", enterpriseqq.getEnterpriseQqLinks());
// 产品已经下架
return "ixinweb/chanpinxiajia";
}
return "ixinweb/zhuce";
}
use of org.codehaus.jackson.JsonGenerationException in project portal by ixinportal.
the class UserInfoWebController method choiceEnterprise.
/**
* 选择企业
*
* @param request
* @return
*/
@RequestMapping("/choiceEnterprise")
public String choiceEnterprise(@RequestParam(value = "noProduct", required = false) String noProduct, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
Boolean webnoProduct = (Boolean) session.getAttribute("webnoProduct");
if (null == userInfo) {
// 登录状态失效,跳转到登录页面
return "redirect:/userInfoWeb/denglu.html";
}
// 查询用户关联的企业list
List<Enterprise> enterpriseList = new ArrayList<Enterprise>();
List<Long> enterpriseIds = userInfoEnterpriseServiceImpl.getEnterpriseByUserInfo(userInfo.getId());
if (null != enterpriseIds && !enterpriseIds.isEmpty()) {
enterpriseList = enterpriseService.getEnterpriseListByIds(enterpriseIds);
}
uiModel.addAttribute("enterpriseSize", enterpriseList.size());
try {
uiModel.addAttribute("enterpriseList", jsonTool.writeValueAsString(enterpriseList));
uiModel.addAttribute("enterprises", enterpriseList);
} 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();
}
// 存在有未关联企业的填写中订单,则添加填写中企业按钮:
uiModel.addAttribute("hasEditBill", 0);
List<EditBill> ebList = editBillService.getEditBill(userInfo.getId(), null);
if (0 != ebList.size() && !ebList.isEmpty()) {
uiModel.addAttribute("hasEditBill", 1);
if (0 == enterpriseList.size()) {
return "redirect:/userInfoWeb/editBillList";
}
}
session.removeAttribute("sessionPlist");
session.removeAttribute("enterpriseqqE");
if (session.getAttribute("webprojectId") != null) {
Long pid = Long.parseLong(session.getAttribute("webprojectId").toString());
System.out.println("userInfo_=" + pid);
if (null != pid) {
// userInfo = userInfoService.getUserInfoById(userInfo.getId());
EnterpriseQqExample enterpriseE = new EnterpriseQqExample();
EnterpriseQqExample.Criteria qqEx = enterpriseE.createCriteria();
qqEx.andProjectIdEqualTo(pid);
EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterpriseE);
if (enterpriseqq != null && enterpriseqq.getEnterpriseQqLinks() != null) {
uiModel.addAttribute("enterpriseqq", enterpriseqq.getEnterpriseQqLinks());
session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
}
}
}
if ("1".equals(noProduct)) {
session.setAttribute("webnoProduct", true);
return "ixinweb/xuanzeqiyeNoProduct";
}
if (null == webnoProduct || webnoProduct) {
// 未携带产品信息
session.setAttribute("webnoProduct", true);
return "ixinweb/xuanzeqiyeNoProduct";
}
return "ixinweb/xuanzeqiye";
}
use of org.codehaus.jackson.JsonGenerationException in project appsly-android-rest by 47deg.
the class JacksonBodyConverter method toRequestBody.
@Override
public <T> HttpEntity toRequestBody(T object, String contentType) {
Logger.d("JacksonBodyConverter.toRequestBody: object: " + object);
try {
String json = mapper.writeValueAsString(object);
Logger.d("JacksonHttpFormValuesConverter.toRequestBody: json: " + json);
StringEntity result = new StringEntity(json, "UTF-8");
result.setContentType(contentType);
Logger.d("JacksonBodyConverter.toRequestBody: result: " + result);
return result;
} catch (UnsupportedEncodingException e) {
throw new SerializationException(e);
} catch (JsonMappingException e) {
throw new SerializationException(e);
} catch (JsonGenerationException e) {
throw new SerializationException(e);
} catch (IOException e) {
throw new SerializationException(e);
}
}
use of org.codehaus.jackson.JsonGenerationException in project spring-data-document-examples by spring-projects.
the class MappingJacksonHttpMessageConverter 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);
}
}
use of org.codehaus.jackson.JsonGenerationException in project coprhd-controller by CoprHD.
the class KHRequests method postRequest.
/*
* Send POST request to KittyHawk server, and handle redirect/cookies
*
* @param resource webResource
*
* @param ParamBase parameters for post
*
* @throws VNXeException
*/
public ClientResponse postRequest(ParamBase param) throws VNXeException {
_logger.debug("post data: " + _url);
ObjectMapper mapper = new ObjectMapper();
String parmString = null;
if (param != null) {
try {
parmString = mapper.writeValueAsString(param);
_logger.debug("Content of the post: {}", parmString);
} catch (JsonGenerationException e) {
_logger.error("Post request param is not valid. ", e);
throw VNXeException.exceptions.vnxeCommandFailed("Post request param is not valid.", e);
} catch (JsonMappingException e) {
_logger.error("Post request param is not valid. ", e);
throw VNXeException.exceptions.vnxeCommandFailed("Post request param is not valid.", e);
} catch (IOException e) {
_logger.error("Post request param is not valid. ", e);
throw VNXeException.exceptions.vnxeCommandFailed("Post request param is not valid.", e);
}
}
ClientResponse response = buildRequest(addQueryParameters(buildResource(_resource)).getRequestBuilder()).entity(parmString).post(ClientResponse.class);
Status statusCode = response.getClientResponseStatus();
if (statusCode == ClientResponse.Status.CREATED || statusCode == ClientResponse.Status.ACCEPTED || statusCode == ClientResponse.Status.OK || statusCode == ClientResponse.Status.NO_CONTENT) {
return response;
} else if (statusCode == ClientResponse.Status.UNAUTHORIZED) {
authenticate();
response = buildRequest(addQueryParameters(buildResource(_resource)).getRequestBuilder()).entity(parmString).post(ClientResponse.class);
;
statusCode = response.getClientResponseStatus();
if (statusCode == ClientResponse.Status.OK || statusCode == ClientResponse.Status.ACCEPTED || statusCode == ClientResponse.Status.NO_CONTENT || statusCode == ClientResponse.Status.CREATED) {
return response;
}
}
int redirectTimes = 1;
// handle redirect
while (response.getClientResponseStatus() == ClientResponse.Status.FOUND && redirectTimes < VNXeConstants.REDIRECT_MAX) {
String code = response.getClientResponseStatus().toString();
String data = response.getEntity(String.class);
_logger.debug("Returned code: {}, returned data {}", code, data);
WebResource newResource = handelRedirect(response);
if (newResource != null) {
response = buildRequest(newResource.getRequestBuilder()).entity(parmString).post(ClientResponse.class);
redirectTimes++;
} else {
// could not find the redirect url, return
_logger.error(String.format("The post request to: %s failed with: %s %s", _url, response.getClientResponseStatus().toString(), response.getEntity(String.class)));
throw VNXeException.exceptions.unexpectedDataError("Got redirect status code, but could not get redirected URL");
}
}
if (redirectTimes >= VNXeConstants.REDIRECT_MAX) {
_logger.error("redirected too many times for the request {}", _url);
throw VNXeException.exceptions.unexpectedDataError("Redirected too many times while sending the request for " + _url);
}
checkResponse(response, POST_REQUEST);
return response;
}
Aggregations