List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:com.ailk.oci.ocnosql.tools.load.mutiple.MutipleColumnImporterMapper.java
/** * Convert a line of TSV text into an HBase table row. *///w ww . j a va 2 s . c om @Override public void map(LongWritable offset, Text value, Context context) throws IOException { byte[] lineBytes = value.getBytes(); ts = System.currentTimeMillis(); try { MutipleColumnImportTsv.TsvParser.ParsedLine parsed = parser.parse(lineBytes, value.getLength()); String newRowKey = rowkeyGenerator.generateByGenRKStep(value.toString(), false);//???rowkey Put put = new Put(newRowKey.getBytes()); for (int i = 0; i < parsed.getColumnCount(); i++) { String columnQualifierStr = new String(parser.getQualifier(i)); String rowStr = newRowKey + new String(parser.getFamily(i) + columnQualifierStr); if (notNeedLoadColumnQulifiers.contains(columnQualifierStr)) { continue; } KeyValue kv = new KeyValue(rowStr.getBytes(), 0, newRowKey.getBytes().length, //roffset,rofflength parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0, parser.getQualifier(i).length, ts, KeyValue.Type.Put, lineBytes, parsed.getColumnOffset(i), parsed.getColumnLength(i)); KeyValue newKv = new KeyValue(newRowKey.getBytes(), kv.getFamily(), kv.getQualifier(), ts, kv.getValue()); kv = null; put.add(newKv); } context.write(new ImmutableBytesWritable(newRowKey.getBytes()), put); } catch (MutipleColumnImportTsv.TsvParser.BadTsvLineException badLine) { if (skipBadLines) { System.err.println("Bad line at offset: " + offset.get() + ":\n" + badLine.getMessage()); incrementBadLineCount(1); return; } else { throw new IOException(badLine); } } catch (IllegalArgumentException e) { if (skipBadLines) { System.err.println("Bad line at offset: " + offset.get() + ":\n" + e.getMessage()); incrementBadLineCount(1); return; } else { throw new IOException(e); } } catch (InterruptedException e) { e.printStackTrace(); } catch (RowKeyGeneratorException e) { System.err.println("gen rowkey error, please check config in the ocnosqlTab.xml." + e.getMessage()); throw new IOException(e); } finally { totalLineCount.increment(1); } }
From source file:com.nec.harvest.controller.HelpController.java
/** * This function will be mapped with URL {@link * /help/save/ organizationCode} /{businessDay}}, it can be used to save * sales data changed. Will be displayed a message when have a exception or * an error occurred./* w ww . j av a 2 s .c om*/ * * @param orgCode * @param monthly * @param params * @param model * @return JSonBean */ @RequestMapping(value = "/save/{orgCode:[a-z0-9]+}/{monthly:[\\d]+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONBean saveHelpData(@PathVariable String proGNo, @PathVariable String orgCode, @PathVariable @MaskFormat("######") String monthly, @RequestBody final List<JSONHelp> jSONHelps, final Model model) { if (logger.isDebugEnabled()) { logger.debug("Saving sales data on month: " + monthly + " of organizetion code: " + orgCode); } try { return helpService.handleHelps(monthly, jSONHelps); } catch (IllegalArgumentException ex) { logger.warn(ex.getMessage()); // return new JSONBean(Boolean.FALSE, 2, MessageHelper.get(MsgConstants.CM_UPD_M03)); } }
From source file:com.transwarp.hbase.bulkload.withindex.TextWithIndexSortReducer.java
@Override protected void reduce(ImmutableBytesWritable rowKey, java.lang.Iterable<Text> lines, Reducer<ImmutableBytesWritable, Text, ImmutableBytesWritable, KeyValue>.Context context) throws java.io.IOException, InterruptedException { // although reduce() is called per-row, handle pathological case long threshold = context.getConfiguration().getLong("reducer.row.threshold", 1L * (1 << 30)); Iterator<Text> iter = lines.iterator(); boolean qualifier = context.getConfiguration().getBoolean("indexqualifier", false); while (iter.hasNext()) { // Get the prefix to judge whethre primary table(Prefix == 0) or index table (prefix > 0) int rowkeyPrefix = Bytes.toInt(rowKey.get(), 0, 4); byte[] rowKeyWithoutPrefix = Bytes.tail(rowKey.get(), rowKey.get().length - 4); Set<KeyValue> map = new TreeSet<KeyValue>(KeyValue.COMPARATOR); long curSize = 0; // stop at the end or the RAM threshold while (iter.hasNext() && curSize < threshold) { Text line = iter.next(); String lineStr = line.toString(); try { Put p = null;//from ww w . java 2s .c o m if (rowkeyPrefix == 0) { ArrayList<String> parsedLine = ParsedLine.parse(converter.getRecordSpec(), lineStr); p = converter.convert(parsedLine, rowKeyWithoutPrefix); } else { p = new Put(rowKeyWithoutPrefix); if (qualifier) { p.add(family, line.getBytes(), emptyByte); } else { p.add(family, this.qualifier, line.getBytes()); } } if (p != null) { for (List<KeyValue> kvs : p.getFamilyMap().values()) { for (KeyValue kv : kvs) { map.add(kv); curSize += kv.getLength(); } } } } catch (FormatException badLine) { if (skipBadLines) { System.err.println("Bad line." + badLine.getMessage()); incrementBadLineCount(1); return; } throw new IOException(badLine); } catch (IllegalArgumentException e) { if (skipBadLines) { System.err.println("Bad line." + e.getMessage()); incrementBadLineCount(1); return; } throw new IOException(e); } } context.setStatus("Read " + map.size() + " entries of " + map.getClass() + "(" + StringUtils.humanReadableInt(curSize) + ")"); int index = 0; for (KeyValue kv : map) { context.write(rowKey, kv); if (++index > 0 && index % 100 == 0) context.setStatus("Wrote " + index + " key values."); } // if we have more entries to process if (iter.hasNext()) { // force flush because we cannot guarantee intra-row sorted order context.write(null, null); } } }
From source file:org.inbio.ait.web.ajax.controller.QueryController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String paramLayer = request.getParameter("layers"); String paramTaxon = request.getParameter("taxons"); String paramIndi = request.getParameter("indi"); String limitPolygons = request.getParameter("limit"); String errorMsj = "Error con los parmetros: " + paramLayer + " " + paramTaxon + " " + paramIndi + " " + limitPolygons;//from ww w .j a v a2 s . c om try { //Arrays that contains the parameters data String[] layerArray = paramLayer.split("\\|"); String[] taxonArray = paramTaxon.split("\\|"); String[] indiArray = paramIndi.split("\\|"); String[] limitArray = limitPolygons.split("\\|"); /*If there is just one criteria category or especifically these categories (geographical-taxonomical or taxonomical-indicator). It means type 0 on xml*/ //------------------------------------------------------------------ if (isOneGeoTaxOrIndiTax(layerArray, taxonArray, indiArray)) { //Total of matches in the limit polygons Long totalLimitMatches = queryManager.countByCriteria(limitArray, taxonArray, indiArray, TaxonInfoIndexColums.SPECIES.getName()); //Total of matches Long totalMatches = queryManager.countByCriteria(layerArray, taxonArray, indiArray, TaxonInfoIndexColums.SPECIES.getName()); //Percentage that represents the total of retrived results Long totalPercentage = 0L; if (totalLimitMatches > 0L) { totalPercentage = (totalMatches * 100) / totalLimitMatches; } return writeReponse0(request, response, totalMatches, totalPercentage); } //If there are three criteria categories. It means type 1 on xml else { //Total of matches in the limit polygons Long totalLimitMatches = queryManager.countByCriteria(limitArray, taxonArray, indiArray, TaxonInfoIndexColums.SPECIES.getName()); //Total of matches Long totalMatches = queryManager.countByCriteria(layerArray, taxonArray, indiArray, TaxonInfoIndexColums.SPECIES.getName()); //Percentage that represents the total of retrived results Long totalPercentage = 0L; if (totalLimitMatches > 0L) { totalPercentage = (totalMatches * 100) / totalLimitMatches; } //Total matches by polygon List<Node> matchesByPolygon = new ArrayList<Node>(); for (int i = 0; i < layerArray.length; i++) { String[] thePolygon = { layerArray[i] }; Long countAbs = queryManager.countByCriteria(thePolygon, taxonArray, indiArray, TaxonInfoIndexColums.SPECIES.getName()); Long percentage = 0L; if (totalLimitMatches > 0) { percentage = (countAbs * 100) / totalLimitMatches; } Node aux = new Node(); //Absulute count,percentage aux.setValue1(countAbs); aux.setValue2(percentage); matchesByPolygon.add(aux); } //Total matches by indicator List<Node> matchesByIndicator = new ArrayList<Node>(); for (int i = 0; i < indiArray.length; i++) { String[] theIndicator = { indiArray[i] }; Long countAbs = queryManager.countByCriteria(layerArray, taxonArray, theIndicator, TaxonInfoIndexColums.SPECIES.getName()); Long percentage = 0L; if (totalLimitMatches > 0) { percentage = (countAbs * 100) / totalLimitMatches; } Node aux = new Node(); //Absulute count,percentage aux.setValue1(countAbs); aux.setValue2(percentage); matchesByIndicator.add(aux); } return writeReponse1(request, response, matchesByPolygon, matchesByIndicator, totalMatches, totalPercentage); } } catch (IllegalArgumentException iae) { throw new Exception(errorMsj + " " + iae.getMessage()); } }
From source file:com.smartbear.collab.client.Client.java
public JsonrpcCommandResponse checkTicket() throws ServerURLException, CredentialsException, Exception { JsonrpcCommandResponse result;/* w w w. j a v a 2s. co m*/ List<JsonrpcCommand> methods = new ArrayList<JsonrpcCommand>(); methods.add(new Authenticate(username, ticketId)); try { JsonrpcResponse response = sendRequest(methods); result = response.getResults().get(0); if (result.getErrors() != null && result.getErrors().size() > 0) { throw new ServerURLException(result.getErrors().get(0).getMessage()); } } catch (IllegalArgumentException iae) { throw new ServerURLException(iae.getMessage()); } catch (ProcessingException pe) { if (pe.getCause().getClass().equals(ConnectException.class)) { throw new ServerURLException(pe.getCause().getMessage()); } else { throw new ServerURLException(pe.getMessage()); } } catch (NotFoundException nfe) { throw new ServerURLException(nfe.getMessage()); } catch (Exception e) { throw new CredentialsException(e.getMessage()); } return result; }
From source file:com.marklogic.contentpump.CompressedAggXMLReader.java
protected void initStreamReader(InputSplit inSplit) throws IOException, InterruptedException { setFile(((FileSplit) inSplit).getPath()); FSDataInputStream fileIn = fs.open(file); String codecString = conf.get(ConfigConstants.CONF_INPUT_COMPRESSION_CODEC, CompressionCodec.ZIP.toString()); if (codecString.equalsIgnoreCase(CompressionCodec.ZIP.toString())) { zipIn = new ZipInputStream(fileIn); codec = CompressionCodec.ZIP;/*from w w w . j a va 2 s . c om*/ while (true) { try { currZipEntry = ((ZipInputStream) zipIn).getNextEntry(); if (currZipEntry == null) { break; } if (currZipEntry.getSize() != 0) { subId = currZipEntry.getName(); break; } } catch (IllegalArgumentException e) { LOG.warn("Skipped a zip entry in : " + file.toUri() + ", reason: " + e.getMessage()); } } if (currZipEntry == null) { // no entry in zip LOG.warn("No valid entry in zip:" + file.toUri()); return; } ByteArrayOutputStream baos; long size = currZipEntry.getSize(); if (size == -1) { baos = new ByteArrayOutputStream(); } else { baos = new ByteArrayOutputStream((int) size); } int nb; while ((nb = zipIn.read(buf, 0, buf.length)) != -1) { baos.write(buf, 0, nb); } try { start = 0; end = baos.size(); xmlSR = f.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray()), encoding); } catch (XMLStreamException e) { LOG.error(e.getMessage(), e); } } else if (codecString.equalsIgnoreCase(CompressionCodec.GZIP.toString())) { zipIn = new GZIPInputStream(fileIn); codec = CompressionCodec.GZIP; try { start = 0; end = inSplit.getLength(); xmlSR = f.createXMLStreamReader(zipIn, encoding); } catch (XMLStreamException e) { LOG.error(e.getMessage(), e); } } else { throw new UnsupportedOperationException("Unsupported codec: " + codec.name()); } if (useAutomaticId) { idGen = new IdGenerator(file.toUri().getPath() + "-" + ((FileSplit) inSplit).getStart()); } }
From source file:org.loklak.api.server.ImportProfileServlet.java
private void doUpdate(RemoteAccess.Post post, HttpServletResponse response) throws IOException { String callback = post.get("callback", null); boolean jsonp = callback != null && callback.length() > 0; String data = post.get("data", ""); if (data == null || data.length() == 0) { response.sendError(400, "your request must contain a data object."); return;// w w w . jav a 2s. c o m } // parse the json data boolean success; try { XContentParser parser = JsonXContent.jsonXContent.createParser(data); Map<String, Object> map = parser.map(); if (map.get("id_str") == null) { throw new IOException("id_str field missing"); } if (map.get("source_type") == null) { throw new IOException("source_type field missing"); } ImportProfileEntry i = DAO.SearchLocalImportProfiles((String) map.get("id_str")); if (i == null) { throw new IOException("import profile id_str field '" + map.get("id_str") + "' not found"); } ImportProfileEntry importProfileEntry; try { importProfileEntry = new ImportProfileEntry(map); } catch (IllegalArgumentException e) { response.sendError(400, "Error updating import profile : " + e.getMessage()); return; } importProfileEntry.setLastModified(new Date()); success = DAO.writeImportProfile(importProfileEntry, true); } catch (IOException | NullPointerException e) { response.sendError(400, "submitted data is invalid : " + e.getMessage()); e.printStackTrace(); return; } post.setResponse(response, "application/javascript"); XContentBuilder json = XContentFactory.jsonBuilder().prettyPrint().lfAtEnd(); json.startObject(); json.field("status", "ok"); json.field("records", success ? 1 : 0); json.field("message", "updated"); json.endObject(); // write json response.setCharacterEncoding("UTF-8"); PrintWriter sos = response.getWriter(); if (jsonp) sos.print(callback + "("); sos.print(json.string()); if (jsonp) sos.println(");"); sos.println(); post.finalize(); }
From source file:com.smartbear.collab.client.Client.java
public JsonrpcCommandResponse getActionItems() throws ServerURLException, CredentialsException, Exception { JsonrpcCommandResponse result;//from w w w. java 2s.c o m List<JsonrpcCommand> methods = new ArrayList<JsonrpcCommand>(); methods.add(new Authenticate(username, ticketId)); methods.add(new GetActionItems()); try { JsonrpcResponse response = sendRequest(methods); result = response.getResults().get(0); if (result.getErrors() != null && result.getErrors().size() > 0) { throw new ServerURLException("Server communication error."); } result = response.getResults().get(1); } catch (IllegalArgumentException iae) { throw new ServerURLException(iae.getMessage()); } catch (ProcessingException pe) { if (pe.getCause().getClass().equals(ConnectException.class)) { throw new ServerURLException(pe.getCause().getMessage()); } else { throw new ServerURLException(pe.getMessage()); } } catch (NotFoundException nfe) { throw new ServerURLException(nfe.getMessage()); } catch (Exception e) { throw new CredentialsException(e.getMessage()); } return result; }
From source file:com.smartbear.collab.client.Client.java
public JsonrpcCommandResponse createReview(String creator, String title) throws ServerURLException, CredentialsException, Exception { JsonrpcCommandResponse result;// w w w . ja v a 2 s . c o m List<JsonrpcCommand> methods = new ArrayList<JsonrpcCommand>(); methods.add(new Authenticate(username, ticketId)); methods.add(new CreateReview(creator, title)); try { JsonrpcResponse response = sendRequest(methods); result = response.getResults().get(0); if (result.getErrors() != null && result.getErrors().size() > 0) { throw new ServerURLException("Server communication error."); } result = response.getResults().get(1); } catch (IllegalArgumentException iae) { throw new ServerURLException(iae.getMessage()); } catch (ProcessingException pe) { if (pe.getCause().getClass().equals(ConnectException.class)) { throw new ServerURLException(pe.getCause().getMessage()); } else { throw new ServerURLException(pe.getMessage()); } } catch (NotFoundException nfe) { throw new ServerURLException(nfe.getMessage()); } catch (Exception e) { throw new CredentialsException(e.getMessage()); } return result; }