use of org.codehaus.jackson.JsonParseException in project coprhd-controller by CoprHD.
the class KHRequests method postRequestAsync.
public VNXeCommandJob postRequestAsync(ParamBase param) {
setAsyncMode();
ClientResponse response = postRequest(param);
VNXeCommandJob job;
String resString = response.getEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
try {
job = mapper.readValue(resString, VNXeCommandJob.class);
} catch (JsonParseException e) {
_logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
} catch (JsonMappingException e) {
_logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
} catch (IOException e) {
_logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
}
if (job != null) {
_logger.info("submitted the job: " + job.getId());
} else {
_logger.warn("No job returned.");
}
return job;
}
use of org.codehaus.jackson.JsonParseException in project coprhd-controller by CoprHD.
the class KHRequests method deleteRequestAsync.
/*
* Send DELETE request to KittyHawk server in async mode
*
* @param resource webResource
*
* @param param parameters for delete
*
* @return VNXeCommandJob
*
* @throws VNXeException
*/
public VNXeCommandJob deleteRequestAsync(Object param) throws VNXeException {
_logger.debug("delete data: " + _url);
setAsyncMode();
ClientResponse response = deleteRequest(param);
VNXeCommandJob job;
String resString = response.getEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
try {
job = mapper.readValue(resString, VNXeCommandJob.class);
} catch (JsonParseException e) {
_logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
} catch (JsonMappingException e) {
_logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
} catch (IOException e) {
_logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
}
if (job != null) {
_logger.info("submitted the deleting file system job: {} ", job.getId());
}
return job;
}
use of org.codehaus.jackson.JsonParseException 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.JsonParseException 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.JsonParseException in project OpenOLAT by OpenOLAT.
the class EdubaseManagerImpl method fetchBookDetails.
@Override
public BookDetails fetchBookDetails(String bookId) {
BookDetails infoReponse = new BookDetailsImpl();
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(TIMEOUT_5000_MILLIS).setConnectTimeout(TIMEOUT_5000_MILLIS).setConnectionRequestTimeout(TIMEOUT_5000_MILLIS).build();
String url = String.format(edubaseModule.getInfoverUrl(), bookId);
HttpGet request = new HttpGet(url);
request.setConfig(requestConfig);
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse httpResponse = httpClient.execute(request)) {
String json = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
ObjectMapper objectMapper = new ObjectMapper();
infoReponse = objectMapper.readValue(json, BookDetailsImpl.class);
} catch (SocketTimeoutException socketTimeoutException) {
log.warn("Socket Timeout while requesting informations of the Edubase book with the id " + bookId);
} catch (JsonParseException | EOFException noesNotExitsException) {
log.debug("Error while requesting informations for the Edubase book with the id " + bookId + ": Book does not exist.");
} catch (Exception e) {
log.error("", e);
}
return infoReponse;
}
Aggregations