use of org.codehaus.jackson.map.JsonMappingException 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.map.JsonMappingException in project portal by ixinportal.
the class MobileAppserviceChargingController method createOrUpdate.
// 新建和修改处理
@RequestMapping(value = "/createOrUpdate", method = RequestMethod.POST, produces = "text/html")
@ResponseBody
public synchronized Map<String, Object> createOrUpdate(@RequestParam("appserviceChargingStr") String appserviceChargingStr) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("flag", false);
DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
// 事物的传播行为,使用同一个事物
dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(dtd);
try {
AppserviceChargingWrap acw = jsonTool.readValue(appserviceChargingStr, AppserviceChargingWrap.class);
List<AppserviceChargingList> appserviceChargingLists = acw.getAppserviceChargingLists();
for (int i = 0; i < appserviceChargingLists.size(); i++) {
// 取出单个的服务名称主表对象和服务名封装list
MobileAppserviceCharging appCharging = appserviceChargingLists.get(i).getAppserviceCharging();
// if (null == appCharging.getChargingType()) {
// cc.setChargingType(ComNames.CHARGING_TYPE_SMRZ_1);
// }
List<AppserviceNameList> appserviceNameLists = appserviceChargingLists.get(i).getAppserviceNameLists();
Map<String, Object> mapAC = new HashMap<String, Object>();
mapAC = appserviceChargingService.saveOrUpdateAppserviceCharging(appCharging);
boolean retCodeAC = false;
retCodeAC = (boolean) mapAC.get("flag");
// 新增或修改MobileAppserviceCharging成功
if (retCodeAC) {
appCharging = (MobileAppserviceCharging) mapAC.get("appserviceCharging");
MobileAppserviceCharging oldAC = (MobileAppserviceCharging) mapAC.get("oldAppserviceCharging");
// 将MobileAppserviceCharging的id值赋值给serviceNameList中新增的服务
appserviceNameLists = appserviceNameService.insertIdIntoAppserviceName(appCharging, appserviceNameLists);
// 2.新增或修改ServiceName
for (int j = 0; j < appserviceNameLists.size(); j++) {
MobileAppserviceName appserviceName = appserviceNameLists.get(j).getAppserviceName();
ChargingPriceList chargingPriceList = appserviceNameLists.get(j).getChargingPriceList();
boolean retCodeSN = false;
Map<String, Object> mapAppserviceName = new HashMap<String, Object>();
mapAppserviceName = appserviceNameService.saveOrUpdateServiceName(appserviceName, appCharging, oldAC);
retCodeSN = (boolean) mapAppserviceName.get("flag");
// 新增或修改ServiceName成功
if (retCodeSN) {
appserviceName = (MobileAppserviceName) mapAppserviceName.get("appserviceName");
MobileAppserviceName oldAppserviceName = (MobileAppserviceName) mapAppserviceName.get("oldAppserviceName");
List<MobileAppserviceName> oldAppserviceNames = (List<MobileAppserviceName>) mapAppserviceName.get("appserviceNames");
// 将serviceNameId,CertificationCharging的id值赋值给chargingPriceList中计费以及价格区间
chargingPriceList = chargingPriceService.insertIdIntoChargingPrice(appserviceName, chargingPriceList);
List<MobileChargingPrice> chargingPrices = chargingPriceList.getChargingPriceLists();
// 3.charprice新增或修改
for (int k = 0; k < chargingPrices.size(); k++) {
Map<String, Object> mapChargingPrice = new HashMap<String, Object>();
mapChargingPrice = chargingPriceService.saveOrUpdateChargingPrice(appCharging, appserviceName, chargingPrices.get(k), oldAC, oldAppserviceName, oldAppserviceNames);
boolean retCodeChargingPrice = false;
retCodeChargingPrice = (boolean) mapChargingPrice.get("flag");
// 新增或修改ChargingPrice失败
if (!retCodeChargingPrice) {
transactionManager.rollback(status);
retMap = mapChargingPrice;
return retMap;
}
}
} else {
// TODO 新增或修改ServiceName错误,返回异常信息
transactionManager.rollback(status);
retMap = mapAppserviceName;
return retMap;
}
}
} else {
// TODO 新增或修改CertificationCharging错误,返回异常信息
transactionManager.rollback(status);
retMap = mapAC;
return retMap;
}
}
LogUtil.adminlog(sqlSession, "新增计费规则", "新增了计费规则");
transactionManager.commit(status);
retMap.put("flag", true);
// 修改应用对应的服务:将应用和服务关联起来
// Set<Long> set = appserviceChargingService.getAllAppId();
// if (null != set && set.size() >0) {
// for (Long long1 : set) {
// Set<Long> AppserviceIDs = appserviceChargingService.getAppserviceIDsByAppId(long1);
// applicationInfoService.addServiceByAppInfo(long1,AppserviceIDs);
// }
// }
// 通知其他机器,加载缓存
CertificationChargingHandler cch = new CertificationChargingHandler();
QueueThread.buildCertificationTask(cch);
// cacheCustomer.initChargeRule();
return retMap;
} catch (JsonParseException e) {
transactionManager.rollback(status);
e.printStackTrace();
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (JsonMappingException e) {
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
e.printStackTrace();
return retMap;
} catch (IOException e) {
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
e.printStackTrace();
return retMap;
} catch (Exception e) {
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
e.printStackTrace();
return retMap;
}
}
use of org.codehaus.jackson.map.JsonMappingException in project openmrs-module-coreapps by openmrs.
the class VisitTypeHelper method getOrderedVisitTypes.
/**
* Returns a list of ordered visit types.
*
* @param visitTypes All the visit types
* @param propertyValue The visit types to order in JSON-like format
* @param visitService
* @return visitTypesOrdered The visit types ordered and merged with the input visit type list
*/
public List<VisitType> getOrderedVisitTypes(List<VisitType> visitTypes, String propertyValue, VisitService visitService) {
Map<Integer, String> order = null;
List<VisitType> visitTypesOrdered = new ArrayList<VisitType>();
if (propertyValue != null) {
try {
order = new ObjectMapper().readValue(propertyValue, HashMap.class);
} catch (JsonParseException e) {
VisitTypeHelper.LOG.error("Unable to parse global property \"" + CoreAppsConstants.VISIT_TYPES_ORDER_PROPERTY + "\"");
} catch (JsonMappingException e) {
VisitTypeHelper.LOG.error("Unable to map global property \"" + CoreAppsConstants.VISIT_TYPES_ORDER_PROPERTY + "\"");
} catch (APIException e) {
VisitTypeHelper.LOG.error("Unable to load global property \"" + CoreAppsConstants.VISIT_TYPES_ORDER_PROPERTY + "\"");
} catch (IOException e) {
VisitTypeHelper.LOG.error("Unable to read global property \"" + CoreAppsConstants.VISIT_TYPES_ORDER_PROPERTY + "\"");
}
}
if (order != null) {
for (int i = 1; i <= order.size(); i++) {
String typeUuid = order.get(Integer.toString(i));
VisitType type = visitService.getVisitTypeByUuid(typeUuid);
if (visitTypes.contains(type)) {
visitTypesOrdered.add(visitService.getVisitTypeByUuid(typeUuid));
}
}
for (VisitType type : visitTypes) {
if (!order.containsValue(type.getUuid())) {
visitTypesOrdered.add(type);
}
}
}
if (!(visitTypes.size() == visitTypesOrdered.size())) {
VisitTypeHelper.LOG.warn("Visit Types order property is not used.");
return visitTypes;
}
return visitTypesOrdered;
}
use of org.codehaus.jackson.map.JsonMappingException in project BetterBatteryStats by asksven.
the class ReferenceDto method toJson.
/**
* Serialize to JSON
* @return
*/
private byte[] toJson() {
byte[] ret = null;
StringWriter buffer = new StringWriter();
ObjectMapper mapper = new ObjectMapper();
// mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
try {
ret = mapper.writeValueAsBytes(this);
// mapper.writeValue(buffer, this);
// ret = buffer.toString();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
use of org.codehaus.jackson.map.JsonMappingException in project coprhd-controller by CoprHD.
the class ServiceCodeExceptionMapperTest method jsonMappingException.
@Test
public void jsonMappingException() {
final JsonMappingException exception = new JsonMappingException("Failed to map JSON content to a Java class");
assertException("Failed to map JSON content to a Java class", 1013, "Bad request body", 400, exception);
}
Aggregations