Parses one or more data points for storage @return an array of data points to process for storage @throws JSONException if parsing failed @throws BadRequestException if the content was missing or parsing failed
()
| 134 | * @throws BadRequestException if the content was missing or parsing failed |
| 135 | */ |
| 136 | @Override |
| 137 | public List<IncomingDataPoint> parsePutV1() { |
| 138 | if (!query.hasContent()) { |
| 139 | throw new BadRequestException("Missing request content"); |
| 140 | } |
| 141 | |
| 142 | // convert to a string so we can handle character encoding properly |
| 143 | final String content = query.getContent().trim(); |
| 144 | final int firstbyte = content.charAt(0); |
| 145 | try { |
| 146 | if (firstbyte == '{') { |
| 147 | final IncomingDataPoint dp = |
| 148 | JSON.parseToObject(content, IncomingDataPoint.class); |
| 149 | final ArrayList<IncomingDataPoint> dps = |
| 150 | new ArrayList<IncomingDataPoint>(1); |
| 151 | dps.add(dp); |
| 152 | return dps; |
| 153 | } else { |
| 154 | return JSON.parseToObject(content, TR_INCOMING); |
| 155 | } |
| 156 | } catch (IllegalArgumentException iae) { |
| 157 | throw new BadRequestException("Unable to parse the given JSON", iae); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Parses one or more data points for storage |
nothing calls this directly
no test coverage detected