List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "Mcu_List_Organ_Device", cmd = "3021") @RequestMapping("/mcu_list_organ_device.xml") public void mcuListOrganDevice(HttpServletRequest request, HttpServletResponse response) throws Exception { Integer startIndex = 0;//from w w w. j av a 2s.co m String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } List<AuthCameraVO> devices = deviceManager.listUserAuthCamera(resource.get().getId()); Element element = deviceManager.listMcuDevice(startIndex, limit, devices); Document doc = new Document(); Element root = new Element("Response"); root.setAttribute("Cmd", "1000"); root.setAttribute("Method", "Login"); root.setAttribute("Code", ErrorCode.SUCCESS); root.setAttribute("Message", ""); doc.setRootElement(root); Element totalCount = new Element("TotalCount"); totalCount.setText(devices.size() + ""); root.addContent(totalCount); root.addContent(element); writePageWithContentLength(response, doc); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "List_Device_Model", cmd = "2041") @RequestMapping("/list_device_model.json") public void listDeviceModel(HttpServletRequest request, HttpServletResponse response) throws Exception { String manufacturerId = request.getParameter("manufacturerId"); Integer startIndex = 0;//from w w w. j av a 2s . c o m String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } Integer totalCount = deviceManager.deviceModeTotalCount(manufacturerId); // omc????? if (startIndex != 0 && totalCount.intValue() != 0) { if (startIndex.intValue() >= totalCount.intValue()) { startIndex -= ((startIndex.intValue() - totalCount.intValue()) / limit + 1) * limit; } } List<DeviceModelVO> deviceModels = deviceManager.listDeviceModel(manufacturerId, startIndex, limit); ListDeviceModelDTO dto = new ListDeviceModelDTO(); dto.setCmd("2041"); dto.setMethod("List_Device_Model"); dto.setListDeviceModel(deviceModels); dto.setTotalCount(totalCount + ""); writePage(response, dto); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "List_Camera", cmd = "2063") @RequestMapping("/list_camera.json") public void listCamera(HttpServletRequest request, HttpServletResponse response) throws Exception { String dvrId = request.getParameter("dvrId"); if (StringUtils.isBlank(dvrId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [dvrId]"); }/*from w w w .j a v a 2 s. c o m*/ Integer startIndex = 0; String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } Integer totalCount = deviceManager.cameraTotalCount(dvrId); // omc????? if (startIndex != 0 && totalCount.intValue() != 0) { if (startIndex.intValue() >= totalCount.intValue()) { startIndex -= ((startIndex.intValue() - totalCount.intValue()) / limit + 1) * limit; } } List<ListCameraVO> vo = deviceManager.listCamera(dvrId, startIndex, limit); ListCameraDTO dto = new ListCameraDTO(); dto.setCmd("2063"); dto.setMethod("List_Camera"); dto.setCameraList(vo); dto.setTotalCount(totalCount + ""); writePage(response, dto); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "List_Dvr", cmd = "2053") @RequestMapping("/list_dvr.json") public void listDvr(HttpServletRequest request, HttpServletResponse response) throws Exception { String organId = request.getParameter("organId"); if (StringUtils.isBlank(organId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]"); }// w w w . j a v a2 s .co m Integer startIndex = 0; String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } Integer totalCount = deviceManager.dvrTotalCount(organId); // omc????? if (startIndex != 0 && totalCount.intValue() != 0) { if (startIndex.intValue() >= totalCount.intValue()) { startIndex -= ((startIndex.intValue() - totalCount.intValue()) / limit + 1) * limit; } } List<DvrVO> listVO = deviceManager.listDvr(organId, startIndex, limit); ListDvrDTO dto = new ListDvrDTO(); dto.setCmd("2053"); dto.setMethod("List_Dvr"); dto.setDvrList(listVO); dto.setTotalCount(totalCount + ""); writePage(response, dto); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "Update_Preset", cmd = "1012") @RequestMapping("/update_preset.xml") public void updatePreset(HttpServletRequest request, HttpServletResponse response) throws Exception { BaseDTO dto = new BaseDTO(); String presetId = request.getParameter("presetId"); if (StringUtils.isBlank(presetId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [presetId]"); }//from w w w. j a va 2s . com Integer presetNumber = null; String presetNumberString = request.getParameter("presetNumber"); if (StringUtils.isNotBlank(presetNumberString)) { try { presetNumber = Integer.parseInt(presetNumberString); } catch (NumberFormatException e) { e.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter presetNumber[" + presetNumberString + "] invalid !"); } } String presetName = request.getParameter("presetName"); presetName = StringUtils.replace(presetName, " ", "+"); // ? Preset preset = deviceManager.getPreset(presetId); GetCameraVO camera = deviceManager.getCamera(preset.getDeviceId()); deviceManager.updatePreset(presetId, presetNumber, presetName); ResourceVO user = resource.get(); // ?? SysLog log = new SysLog(); log.setResourceId(user.getId()); log.setResourceName(user.getName()); log.setResourceType(user.getType()); log.setTargetId(presetId); log.setTargetName(camera.getName() + "" + preset.getName()); log.setTargetType("Preset"); log.setLogTime(System.currentTimeMillis()); log.setOperationType("update"); log.setOperationName(""); log.setOperationCode("1012"); log.setSuccessFlag(ErrorCode.SUCCESS); log.setCreateTime(System.currentTimeMillis()); log.setOrganId(user.getOrganId()); sysLogManager.batchLog(log); dto.setMethod("Update_Preset"); dto.setCmd("1012"); Document doc = new Document(); Element root = ElementUtil.createElement("Response", dto, null, null); doc.setRootElement(root); writePageWithContentLength(response, doc); }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Parse the events file to extract years with events * // w ww. j a va2 s . c om * @return */ public Boolean parseEventListFile() { File f = new File(this.txtEventListFile.getText()); if (!f.exists()) { log.error("Event list file does not exist"); return false; } FileReader fr = null; BufferedReader br = null; String record = null; events = new ArrayList<Integer>(); try { fr = new FileReader(txtEventListFile.getText()); br = new BufferedReader(fr); while ((record = br.readLine()) != null) { if (!record.contains("*")) { try { events.add(new Integer(record)); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, "The event file must contain a list of integer values after any comment lines.\nPlease check the file and try again.", "Warning", JOptionPane.ERROR_MESSAGE); txtEventListFile.setText(""); fr.close(); br.close(); return false; } } } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error reading events file.\nPlease check the file and try again.", "Warning", JOptionPane.ERROR_MESSAGE); txtEventListFile.setText(""); return false; } finally { try { fr.close(); br.close(); } catch (IOException e) { e.printStackTrace(); } } Collections.sort(events); return true; }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "List_Camera_By_Device", cmd = "2066") @RequestMapping("/list_camera_by_device.json") public void listCameraByDevice(HttpServletRequest request, HttpServletResponse response) throws Exception { String organId = request.getParameter("organId"); if (StringUtils.isBlank(organId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]"); }//from w w w. ja va 2 s . co m String name = request.getParameter("name"); name = StringUtils.replace(name, " ", "+"); String stakeNumber = request.getParameter("stakeNumber"); stakeNumber = StringUtils.replace(stakeNumber, " ", "+"); String manufacturerId = request.getParameter("manufacturerId"); String standardNumber = request.getParameter("standardNumber"); Integer startIndex = 0; String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } String organs[] = organManger.listOrganAllChildren(organId); Integer totalCount = deviceManager.cameraByDeviceTotalCount(organs, name, stakeNumber, manufacturerId, standardNumber); // omc????? if (startIndex != 0 && totalCount.intValue() != 0) { if (startIndex.intValue() >= totalCount.intValue()) { startIndex -= ((startIndex.intValue() - totalCount.intValue()) / limit + 1) * limit; } } List<ListCameraVO> vo = deviceManager.listCameraByDevice(organs, name, stakeNumber, manufacturerId, startIndex, limit, standardNumber); ListCameraDTO dto = new ListCameraDTO(); dto.setCmd("2066"); dto.setMethod("List_Camera_By_Device"); dto.setCameraList(vo); dto.setTotalCount(totalCount + ""); writePage(response, dto); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "Create_Preset", cmd = "1011") @RequestMapping("/create_preset.xml") public void createPreset(HttpServletRequest request, HttpServletResponse response) throws Exception { String vicId = request.getParameter("vicId"); if (StringUtils.isBlank(vicId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [vicId]"); }/* w w w. ja va 2 s . c o m*/ Integer presetNumber = null; String presetNumberString = request.getParameter("presetNumber"); if (StringUtils.isBlank(presetNumberString)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [presetNumber]"); } else { try { presetNumber = Integer.parseInt(presetNumberString); } catch (NumberFormatException e) { e.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter presetNumber[" + presetNumberString + "] invalid !"); } } String presetName = request.getParameter("presetName"); if (StringUtils.isBlank(presetName)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [presetName]"); } presetName = StringUtils.replace(presetName, " ", "+"); // String presetId = deviceManager.createPreset(vicId, presetNumber, presetName); // ? GetCameraVO camera = deviceManager.getCamera(vicId); ResourceVO user = resource.get(); // ?? SysLog log = new SysLog(); log.setResourceId(user.getId()); log.setResourceName(user.getName()); log.setResourceType(user.getType()); log.setTargetId(presetId); log.setTargetName(camera.getName() + "" + presetName); log.setTargetType("Preset"); log.setLogTime(System.currentTimeMillis()); log.setOperationType("create"); log.setOperationName(""); log.setOperationCode("1011"); log.setSuccessFlag(ErrorCode.SUCCESS); log.setCreateTime(System.currentTimeMillis()); log.setOrganId(user.getOrganId()); sysLogManager.batchLog(log); Document doc = new Document(); Element root = new Element("Response"); root.setAttribute("Method", "Create_Preset"); root.setAttribute("Cmd", "1011"); root.setAttribute("Code", ErrorCode.SUCCESS); root.setAttribute("Message", ""); doc.setRootElement(root); Element preset = new Element("Preset"); preset.setAttribute("Id", presetId + ""); root.addContent(preset); writePageWithContentLength(response, doc); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "List_Solar_Bind_Device", cmd = "2396") @RequestMapping("/list_solar_bind_device.json") public void listSolarBindDevice(HttpServletRequest request, HttpServletResponse response) throws Exception { String organId = request.getParameter("organId"); if (StringUtils.isBlank(organId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]"); }//from w w w. j a va2 s . c o m String solarId = request.getParameter("solarId"); if (StringUtils.isBlank(solarId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [solarId]"); } String type = request.getParameter("type"); if (StringUtils.isBlank(type)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [type]"); } String name = request.getParameter("name"); int startIndex = 0; String startIndexString = request.getParameter("startIndex"); if (StringUtils.isNotBlank(startIndexString)) { try { startIndex = Integer.parseInt(startIndexString); } catch (NumberFormatException e) { e.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + startIndexString + "] invalid !"); } } int limit = 10; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException e) { e.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } List<DevicePermissionVO> deviceList = null; int totalCount = 0; if ((TypeDefinition.DEVICE_TYPE_CAMERA + "").equals(type)) { totalCount = deviceManager.countOrganCamera(organId, solarId, name); // omc????? if (startIndex != 0 && totalCount != 0) { if (startIndex >= totalCount) { startIndex -= ((startIndex - totalCount) / limit + 1) * limit; } } deviceList = deviceManager.listOrganCamera(organId, solarId, name, startIndex, limit); } else if ((TypeDefinition.DEVICE_TYPE_VD + "").equals(type)) { totalCount = deviceManager.countOrganVD(organId, solarId, name); // omc????? if (startIndex != 0 && totalCount != 0) { if (startIndex >= totalCount) { startIndex -= ((startIndex - totalCount) / limit + 1) * limit; } } deviceList = deviceManager.listOrganVD(organId, solarId, name, startIndex, limit); } else { throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter type[" + type + "] invalid !"); } ListSolarDeviceDTO dto = new ListSolarDeviceDTO(); dto.setCmd("2396"); dto.setMethod("List_Solar_Bind_Device"); dto.setTotalCount(totalCount + ""); dto.setSolarDevices(deviceList); writePage(response, dto); }
From source file:com.znsx.cms.web.controller.DeviceController.java
@InterfaceDescription(logon = true, method = "List_Device_Alarm", cmd = "2463") @RequestMapping("/list_device_alarm.json") public void listDeviceAlarm(HttpServletRequest request, HttpServletResponse response) throws Exception { SimpleRequestReader reader = new SimpleRequestReader(request); String deviceName = reader.getString("deviceName", true); deviceName = StringUtils.replace(deviceName, " ", "+"); String alarmType = reader.getString("alarmType", true); String deviceType = reader.getString("deviceType", true); String organId = reader.getString("organId", true); Long beginTime = reader.getLong("beginTime", true); Long endTime = reader.getLong("endTime", true); // 1/*from w w w .j av a 2 s.c o m*/ if (null == beginTime) { beginTime = System.currentTimeMillis() - 1000 * 60 * 60 * 24; } if (null == endTime) { endTime = System.currentTimeMillis(); } // json? String flag = reader.getString("flag", true); Integer startIndex = 0; String startIndexString = request.getParameter("startIndex"); if (StringUtils.isNotBlank(startIndexString)) { try { startIndex = Integer.parseInt(startIndexString); } catch (NumberFormatException be) { be.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter priority[" + startIndexString + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException be) { be.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter priority[" + limitString + "] invalid !"); } } Integer totalCount = deviceManager.deviceAlarmTotalCount(deviceName, deviceType, organId, beginTime, endTime, alarmType); List<DeviceAlarmVO> list = deviceManager.listDeviceAlarmByOrganId(deviceName, deviceType, organId, beginTime, endTime, startIndex, limit, alarmType); if (StringUtils.isNotBlank(flag)) { DeviceAlarmDTO dto = new DeviceAlarmDTO(); dto.setCmd("2463"); dto.setMethod("List_Device_Alarm"); dto.setDeviceOnlineHistory(list); dto.setTotalCount(totalCount + ""); writePage(response, dto); } else { BaseDTO dto = new BaseDTO(); dto.setCmd("2463"); dto.setMethod("List_Device_Alarm"); dto.setMessage(totalCount + ""); Document doc = new Document(); Element root = ElementUtil.createElement("Response", dto); doc.setRootElement(root); for (DeviceAlarmVO vo : list) { Element deviceAlarm = ElementUtil.createElement("DeviceAlarm", vo); root.addContent(deviceAlarm); } writePageWithContentLength(response, doc); } }