List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:eu.trentorise.opendata.jackan.ckan.CkanClient.java
/** * Updates a resource on the ckan server. * * @param resource ckan resource object// w w w .j a va 2s. com * @return the updated resource * @throws JackanException */ public synchronized CkanResource updateResource(CkanResource resource, Boolean checkConsistency) { if (ckanToken == null) { throw new JackanException( "Tried to update resource" + resource.getName() + ", but ckan token was not set!"); } //check consistance with original version of the to be updated resource if (checkConsistency) { CkanResource originalResource = getResource(resource.getId()); for (Field f : originalResource.getClass().getDeclaredFields()) { f.setAccessible(true); String fieldName; try { if ((f.get(originalResource) != null) && (f.get(resource) == null) && (!f.getName().equals("created"))) { fieldName = f.getName(); // if(!fieldName.equals("created")){ f.set(resource, f.get(originalResource)); System.out.println("Not a null: " + fieldName + " Value: "); // //}; // System.out.println("Not a null: "+fieldName+ " Value: "); } } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } //System.out.println("After consistance checking resource is consist of: "+resource.toString()); ObjectMapper objectMapper = CkanClient.getObjectMapper(); String json = null; try { json = objectMapper.writeValueAsString(resource); } catch (IOException e) { throw new JackanException("Couldn't serialize the provided CkanResourceMinimized!", e); } return postHttp(ResourceResponse.class, "/api/3/action/resource_update", json, ContentType.APPLICATION_JSON).result; }
From source file:org.apache.flink.streaming.connectors.kafka.KafkaConsumerTest.java
@Test public void testValidateZooKeeperConfig() { try {// w w w. jav a 2 s .c o m // empty Properties emptyProperties = new Properties(); try { FlinkKafkaConsumer08.validateZooKeeperConfig(emptyProperties); fail("should fail with an exception"); } catch (IllegalArgumentException e) { // expected } // no connect string (only group string) Properties noConnect = new Properties(); noConnect.put(ConsumerConfig.GROUP_ID_CONFIG, "flink-test-group"); try { FlinkKafkaConsumer08.validateZooKeeperConfig(noConnect); fail("should fail with an exception"); } catch (IllegalArgumentException e) { // expected } // no group string (only connect string) Properties noGroup = new Properties(); noGroup.put("zookeeper.connect", "localhost:47574"); try { FlinkKafkaConsumer08.validateZooKeeperConfig(noGroup); fail("should fail with an exception"); } catch (IllegalArgumentException e) { // expected } } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:com.irccloud.android.Notifications.java
public void updateTeslaUnreadCount() { try {//from w ww. j a v a 2 s . co m IRCCloudApplication.getInstance().getApplicationContext().getPackageManager() .getPackageInfo("com.teslacoilsw.notifier", PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { return; } int count = 0; synchronized (mNotifications) { for (int i = 0; i < mNotifications.size(); i++) { Notification n = mNotifications.get(i); if (n.bid != excludeBid) { count++; } } } try { ContentValues cv = new ContentValues(); cv.put("tag", IRCCloudApplication.getInstance().getApplicationContext().getPackageManager() .getLaunchIntentForPackage( IRCCloudApplication.getInstance().getApplicationContext().getPackageName()) .getComponent().flattenToString()); cv.put("count", count); IRCCloudApplication.getInstance().getApplicationContext().getContentResolver() .insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (IllegalArgumentException ex) { } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.linkedin.harisekhon.CLI.java
public final void main2(String[] args) { log.trace("running CLI.main2()"); setup();//from w w w . j a v a2 s .co m try { addOptions(); } catch (IllegalArgumentException e) { usage(e); } try { parseArgs2(args); // autoflush(); // TODO: this will reduce TRACE level, check to only increase log level and never reduce it // if(verbose > 2) { // log.setLevel(Level.DEBUG); // } else if(verbose > 1){ // log.setLevel(Level.INFO); // } // if(debug){ // log.setLevel(Level.DEBUG); // } } catch (Exception e) { if (log.isDebugEnabled()) { e.printStackTrace(); } usage(e.getMessage()); } log.info(String.format("verbose level: %s", verbose)); validateInt(timeout, "timeout", 0, timeout_max); log.info(String.format("setting timeout to %s secs", timeout)); Thread t = new Thread(new Timeout(timeout)); t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { if (e instanceof QuitException) { println(((QuitException) e).status + ": " + ((QuitException) e).message); System.exit(getStatusCode("UNKNOWN")); } else { // normal Thread.stop() at end of program raises exception with null if (e.getMessage() != null) { println(e.getMessage()); System.exit(getStatusCode("UNKNOWN")); } } } }); t.start(); try { log.trace("running CLI.processArgs()"); processArgs(); log.trace("running CLI.run()"); run(); log.trace("running CLI.end()"); end(); log.trace("stopping timeout thread"); t.stop(); } catch (IllegalArgumentException e) { log.trace("caught exception in CLI.main2()"); if (log.isDebugEnabled()) { e.printStackTrace(); // not as nicely formatted - not printing anything right now?? // println(e.getStackTrace().toString()); } usage(e.getMessage()); // not thrown by try block, how is Control-C thrown? // } catch (InterruptedException e){ // System.out.println("Caught control-c..."); // System.exit(getStatusCode("UNKNOWN")); } }
From source file:org.matsim.counts.algorithms.CountSimComparisonKMLWriter.java
/** * Creates the CountsErrorGraph for all the data * @param visible true if initially visible * @return the ScreenOverlay Feature/*w ww . j av a 2 s.c o m*/ */ private ScreenOverlayType createBoxPlotErrorGraph() { CountsGraph ep; try { ep = new BoxPlotErrorGraph(this.countComparisonFilter.getCountsForHour(null), this.iterationNumber, null, "error graph"); ep.createChart(0); } catch (IllegalArgumentException e) { log.error("Could not create BoxPlot-ErrorGraph.", e); return null; } String filename = "errorGraphBoxPlot.png"; try { writeChartToKmz(filename, ep.getChart()); return createOverlayBottomRight(filename, "Error Graph [Box-Plot]"); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:de.geeksfactory.opacclient.apis.Zones.java
private DetailledItem parse_result(String id, String html) { Document doc = Jsoup.parse(html); DetailledItem result = new DetailledItem(); result.setTitle(""); boolean title_is_set = false; result.setId(id);//from w w w. j a va 2 s . c o m String detailTrsQuery = version18 ? ".inRoundBox1 table table tr" : ".DetailDataCell table table:not(.inRecordHeader) tr"; Elements detailtrs1 = doc.select(detailTrsQuery); for (int i = 0; i < detailtrs1.size(); i++) { Element tr = detailtrs1.get(i); int s = tr.children().size(); if (tr.child(0).text().trim().equals("Titel") && !title_is_set) { result.setTitle(tr.child(s - 1).text().trim()); title_is_set = true; } else if (s > 1) { Element valchild = tr.child(s - 1); if (valchild.select("table").isEmpty()) { String val = valchild.text().trim(); if (val.length() > 0) { result.addDetail(new Detail(tr.child(0).text().trim(), val)); } } } } for (Element a : doc.select("a.SummaryActionLink")) { if (a.text().contains("Vormerken")) { result.setReservable(true); result.setReservation_info(a.attr("href")); } } Elements detaildiv = doc.select("div.record-item-new"); if (!detaildiv.isEmpty()) { for (int i = 0; i < detaildiv.size(); i++) { Element dd = detaildiv.get(i); String text = ""; for (Node node : dd.childNodes()) { if (node instanceof TextNode) { String snip = ((TextNode) node).text(); if (snip.length() > 0) { text += snip; } } else if (node instanceof Element) { if (((Element) node).tagName().equals("br")) { text += "\n"; } else { String snip = ((Element) node).text().trim(); if (snip.length() > 0) { text += snip; } } } } result.addDetail(new Detail("", text)); } } if (doc.select("span.z3988").size() > 0) { // Sometimes there is a <span class="Z3988"> item which provides // data in a standardized format. String z3988data = doc.select("span.z3988").first().attr("title").trim(); for (String pair : z3988data.split("&")) { String[] nv = pair.split("=", 2); if (nv.length == 2) { if (!nv[1].trim().equals("")) { if (nv[0].equals("rft.btitle") && result.getTitle().length() == 0) { result.setTitle(nv[1]); } else if (nv[0].equals("rft.atitle") && result.getTitle().length() == 0) { result.setTitle(nv[1]); } else if (nv[0].equals("rft.au")) { result.addDetail(new Detail("Author", nv[1])); } } } } } // Cover if (doc.select(".BookCover, .LargeBookCover").size() > 0) { result.setCover(doc.select(".BookCover, .LargeBookCover").first().attr("src")); } Elements copydivs = doc.select("div[id^=stock_]"); String pop = ""; for (int i = 0; i < copydivs.size(); i++) { Element div = copydivs.get(i); if (div.attr("id").startsWith("stock_head")) { pop = div.text().trim(); continue; } Copy copy = new Copy(); DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN); // This is getting very ugly - check if it is valid for libraries which are not Hamburg. // Seems to also work in Kiel (Zones 1.8, checked 10.10.2015) int j = 0; for (Node node : div.childNodes()) { try { if (node instanceof Element) { if (((Element) node).tag().getName().equals("br")) { copy.setBranch(pop); result.addCopy(copy); j = -1; } else if (((Element) node).tag().getName().equals("b") && j == 1) { copy.setLocation(((Element) node).text()); } else if (((Element) node).tag().getName().equals("b") && j > 1) { copy.setStatus(((Element) node).text()); } j++; } else if (node instanceof TextNode) { if (j == 0) { copy.setDepartment(((TextNode) node).text()); } if (j == 2) { copy.setBarcode(((TextNode) node).getWholeText().trim().split("\n")[0].trim()); } if (j == 6) { String text = ((TextNode) node).text().trim(); String date = text.substring(text.length() - 10); try { copy.setReturnDate(fmt.parseLocalDate(date)); } catch (IllegalArgumentException e) { e.printStackTrace(); } } j++; } } catch (Exception e) { e.printStackTrace(); } } } return result; }
From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java
/** * Gets the properties of the current graph by clicking on the property * button//from ww w. j av a 2 s . c o m * * @param evt */ private void propertyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_propertyButtonActionPerformed try { mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (jTextArea1.getText() == null) { throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file"); } if (!jTextArea1.getText().contains(".gml")) { throw new IllegalArgumentException( "The chosen file doesn't have the right format!\nPlease choose a valid .gml file"); } if (scgc == null || !scgc.getFileName().equals(fileName)) { scgc = new DegreeSignalCollectGephiConnectorImpl(fileName); } propertyContentDisplay.setText(setPropertyText(scgc.getGraphProperties())); } catch (IllegalArgumentException exception) { messageFrame = new JFrame(); JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } catch (Exception exception) { messageFrame = new JFrame(); exception.printStackTrace(); JOptionPane.showMessageDialog(messageFrame, "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } finally { mainPanel.setCursor(Cursor.getDefaultCursor()); } }
From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java
/** * Gets and visualizes the chart of the Degree Distribution * * @param evt// w w w .j a va2 s .c o m */ private void degreeDistributionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_degreeDistributionButtonActionPerformed try { mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (jTextArea1.getText() == null) { throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file"); } if (!jTextArea1.getText().contains(".gml")) { throw new IllegalArgumentException( "The chosen file doesn't have the right format!\nPlease choose a valid .gml file"); } distributionFrame.setVisible(false); distributionFrame = new JFrame(); scgc = new DegreeSignalCollectGephiConnectorImpl(fileName); JFreeChart chart = scgc.createDegreeDistributionChart(scgc.getDegreeDistribution()); ChartPanel chartPanel = new ChartPanel(chart); Dimension dim = new Dimension(750, 450); distributionFrame.setMinimumSize(dim); distributionFrame.add(chartPanel); chartPanel.setVisible(true); chartPanel.validate(); distributionFrame.pack(); distributionFrame.setVisible(true); } catch (IllegalArgumentException exception) { messageFrame = new JFrame(); JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } catch (Exception exception) { messageFrame = new JFrame(); exception.printStackTrace(); JOptionPane.showMessageDialog(messageFrame, "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } finally { mainPanel.setCursor(Cursor.getDefaultCursor()); } }
From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java
/** * Gets and visualizes the chart of the Local Cluster Coefficient * Distribution/*from www.j a va 2s .c o m*/ * * @param evt */ private void clusterDistributionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clusterDistributionButtonActionPerformed try { mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (jTextArea1.getText() == null) { throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file"); } if (!jTextArea1.getText().contains(".gml")) { throw new IllegalArgumentException( "The chosen file doesn't have the right format!\nPlease choose a valid .gml file"); } distributionFrame.setVisible(false); distributionFrame = new JFrame(); scgc = new LocalClusterCoefficientSignalCollectGephiConnectorImpl(fileName); JFreeChart chart = scgc.createClusterDistributionChart(scgc.getClusterDistribution()); ChartPanel chartPanel = new ChartPanel(chart); Dimension dim = new Dimension(750, 450); distributionFrame.setMinimumSize(dim); chartPanel.setVisible(true); chartPanel.validate(); distributionFrame.add(chartPanel); distributionFrame.pack(); distributionFrame.setVisible(true); } catch (IllegalArgumentException exception) { messageFrame = new JFrame(); JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } catch (Exception exception) { messageFrame = new JFrame(); exception.printStackTrace(); JOptionPane.showMessageDialog(messageFrame, "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } finally { mainPanel.setCursor(Cursor.getDefaultCursor()); } }
From source file:com.xtremelabs.imageutils.DefaultNetworkRequestCreator.java
@Override public void getInputStream(String url, InputStreamListener listener) { HttpEntity entity = null;//w w w.j a v a 2 s. c o m InputStream inputStream = null; HttpClient client = new DefaultHttpClient(); client.getConnectionManager().closeExpiredConnections(); HttpUriRequest request; try { request = new HttpGet(url); } catch (IllegalArgumentException e) { try { request = new HttpGet(URLEncoder.encode(url, "UTF-8")); } catch (UnsupportedEncodingException e1) { String errorMessage = "Unable to download image. Reason: Bad URL. URL: " + url; Log.w(ImageLoader.TAG, errorMessage); listener.onFailure(errorMessage); return; } } HttpResponse response; try { response = client.execute(request); entity = response.getEntity(); if (entity == null) { listener.onFailure("Was unable to retrieve an HttpEntity for the image!"); return; } inputStream = new BufferedInputStream(entity.getContent()); listener.onInputStreamReady(inputStream); } catch (IOException e) { listener.onFailure("IOException caught when attempting to download an image! Stack trace below. URL: " + url + ", Message: " + e.getMessage()); e.printStackTrace(); } try { if (entity != null) { entity.consumeContent(); } } catch (IOException e) { } client.getConnectionManager().closeExpiredConnections(); }