List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testValidateBadRecordsLoggerEnableWithProperValue() throws IOException { String path = "./testValidateBadRecordsLoggerEnableValue"; Field[] fields = new Field[2]; fields[0] = new Field("stringField", DataTypes.STRING); fields[1] = new Field("varcharField", DataTypes.VARCHAR); Schema schema = new Schema(fields); Map map = new HashMap(); map.put("bad_records_logger_enable", "FALSE"); try {//from w w w . j a va 2 s .c o m CarbonWriter.builder().outputPath(path).withLoadOptions(map).withCsvInput(schema) .enableLocalDictionary(false).writtenBy("CarbonReaderTest").build(); } catch (IllegalArgumentException e) { e.printStackTrace(); Assert.fail(); } catch (Exception e) { Assert.fail(e.getMessage()); } finally { FileUtils.deleteDirectory(new File(path)); } }
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testValidateQuoteCharWithProperValue() throws IOException { String path = "./testValidateQuoteCharWithProperValue"; Field[] fields = new Field[2]; fields[0] = new Field("stringField", DataTypes.STRING); fields[1] = new Field("varcharField", DataTypes.VARCHAR); Schema schema = new Schema(fields); Map map = new HashMap(); map.put("quotechar", "#"); try {/* ww w. j a v a 2 s. com*/ CarbonWriter.builder().outputPath(path).withLoadOptions(map).withCsvInput(schema) .enableLocalDictionary(false).writtenBy("CarbonReaderTest").build(); } catch (IllegalArgumentException e) { e.printStackTrace(); Assert.fail(); } catch (Exception e) { Assert.fail(e.getMessage()); } finally { FileUtils.deleteDirectory(new File(path)); } }
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testValidateEscapeCharWithProperValue() throws IOException { String path = "./testValidateEscapeCharWithProperValue"; Field[] fields = new Field[2]; fields[0] = new Field("stringField", DataTypes.STRING); fields[1] = new Field("varcharField", DataTypes.VARCHAR); Schema schema = new Schema(fields); Map map = new HashMap(); map.put("escapechar", "#"); try {// w ww.j av a2 s .c om CarbonWriter.builder().outputPath(path).withLoadOptions(map).withCsvInput(schema) .enableLocalDictionary(false).writtenBy("CarbonReaderTest").build(); } catch (IllegalArgumentException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } catch (Exception e) { Assert.fail(e.getMessage()); } finally { FileUtils.deleteDirectory(new File(path)); } }
From source file:contestWebsite.PublicResults.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "html/pages, html/snippets, html/templates"); ve.init();// ww w. j a v a 2 s .c o m VelocityContext context = new VelocityContext(); Pair<Entity, UserCookie> infoAndCookie = init(context, req); UserCookie userCookie = infoAndCookie.y; boolean loggedIn = (boolean) context.get("loggedIn"); Map<String, Integer> awardCriteria = Retrieve.awardCriteria(infoAndCookie.x); if (!loggedIn && req.getParameter("refresh") != null && req.getParameter("refresh").equals("1")) { resp.sendRedirect("/?refresh=1"); } Entity contestInfo = infoAndCookie.x; context.put("testsGradedNums", contestInfo.hasProperty("testsGradedNums") && contestInfo.getProperty("testsGradedNums") != null ? ((Text) contestInfo.getProperty("testsGradedNums")).getValue() : "{}"); if (contestInfo.hasProperty("testsGraded") && contestInfo.getProperty("testsGraded") != null) { context.put("testsGraded", contestInfo.getProperty("testsGraded")); } Object complete = contestInfo.getProperty("complete"); if (complete != null && (Boolean) complete || loggedIn && userCookie.isAdmin()) { context.put("complete", true); String type = req.getParameter("type"); context.put("type", type); if (type != null) { String[] types = type.split("_"); String levelString = req.getParameter("level"); Level level; try { level = Level.fromString(levelString); } catch (IllegalArgumentException e) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid level: " + levelString); return; } context.put("level", level.toString()); context.put("tests", Test.getTests(level)); context.put("Test", Test.class); if (type.startsWith("category_")) { context.put("test", Test.fromString(types[1])); context.put("trophy", awardCriteria.get("category_" + level + "_trophy")); context.put("medal", awardCriteria.get("category_" + level + "_medal")); context.put("winners", Retrieve.categoryWinners(types[1], level)); } else if (type.startsWith("qualifying_")) { context.put("School", School.class); Pair<School, List<Student>> schoolAndStudents = Retrieve.schoolStudents(types[1], level); context.put("school", schoolAndStudents.x); context.put("students", schoolAndStudents.y); } else if (type.startsWith("categorySweep")) { context.put("trophy", awardCriteria.get("categorySweep_" + level)); context.put("winners", Retrieve.categorySweepstakesWinners(level)); } else if (type.equals("sweep")) { context.put("trophy", awardCriteria.get("sweepstakes_" + level)); context.put("winners", Retrieve.sweepstakesWinners(level)); } else if (type.equals("visualizations")) { Map<Test, Statistics> statistics; try { statistics = Retrieve.visualizations(level); } catch (JSONException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); e.printStackTrace(); return; } context.put("statistics", statistics); } else { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid type: " + type); return; } } else { context.put("type", "avail"); } } else { context.put("complete", false); } Map<Level, List<String>> schools = new HashMap<Level, List<String>>(); for (Level level : Level.values()) { schools.put(level, Retrieve.schoolNames(level)); } context.put("schools", schools); context.put("qualifyingCriteria", Retrieve.qualifyingCriteria(infoAndCookie.x)); context.put("hideFullNames", contestInfo.getProperty("hideFullNames")); context.put("date", contestInfo.getProperty("updated")); context.put("subjects", Subject.values()); context.put("Level", Level.class); context.put("levels", Level.values()); context.put("esc", new EscapeTool()); close(context, ve.getTemplate("publicResults.html"), resp); }
From source file:com.genscript.gsscm.order.web.OrderAction.java
public String saveSaleInfo() { OrderMainDTO sessOrder = (OrderMainDTO) SessionUtil.getRow(SessionConstant.Order.value(), this.sessOrderNo); try {/*from w ww . ja v a2 s . co m*/ boolean bInternal = false;// ?? if (this.order.getCustNo() == -1) { bInternal = true; } ModelUtils.mergerModel(this.order, sessOrder); if (bInternal) { sessOrder.setCustNo(-1); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } SessionUtil.insertRow(SessionConstant.Order.value(), this.sessOrderNo, sessOrder); Struts2Util.renderJson("successful"); return null; }
From source file:me.ryanhamshire.griefprevention.GriefPreventionPlugin.java
public void loadConfig() { try {//from w w w .j a v a 2s . co m if (Files.notExists(DataStore.dataLayerFolderPath)) { Files.createDirectories(DataStore.dataLayerFolderPath); } if (Files.notExists(DataStore.softMuteFilePath)) { Files.createFile(DataStore.softMuteFilePath); } DataStore.loadBannedWords(); Path rootConfigPath = this.getConfigPath().resolve("worlds"); DataStore.globalConfig = new GriefPreventionConfig<GlobalConfig>(Type.GLOBAL, rootConfigPath.resolve("global.conf")); String localeString = DataStore.globalConfig.getConfig().message.locale; try { LocaleUtils.toLocale(localeString); } catch (IllegalArgumentException e) { e.printStackTrace(); this.logger.error("Could not validate the locale '" + localeString + "'. Defaulting to 'en_US'..."); localeString = "en_US"; } final Path localePath = this.getConfigPath().resolve("lang").resolve(localeString + ".conf"); if (!localePath.toFile().exists()) { // Check for a default locale asset and copy to lang folder final Asset asset = this.pluginContainer.getAsset("lang/" + localeString + ".conf").orElse(null); if (asset != null) { asset.copyToDirectory(localePath.getParent()); } } messageStorage = new MessageStorage(localePath); messageData = messageStorage.getConfig(); DataStore.USE_GLOBAL_PLAYER_STORAGE = DataStore.globalConfig .getConfig().playerdata.useGlobalPlayerDataStorage; GPFlags.populateFlagStatus(); CLAIM_BLOCK_SYSTEM = DataStore.globalConfig.getConfig().playerdata.claimBlockSystem; this.modificationTool = Sponge.getRegistry() .getType(ItemType.class, DataStore.globalConfig.getConfig().claim.modificationTool) .orElse(ItemTypes.GOLDEN_SHOVEL); this.investigationTool = Sponge.getRegistry() .getType(ItemType.class, DataStore.globalConfig.getConfig().claim.investigationTool) .orElse(ItemTypes.STICK); this.maxInspectionDistance = DataStore.globalConfig.getConfig().general.maxClaimInspectionDistance; for (World world : Sponge.getGame().getServer().getWorlds()) { DimensionType dimType = world.getProperties().getDimensionType(); Path dimPath = rootConfigPath.resolve(((IMixinDimensionType) dimType).getModId()) .resolve(((IMixinDimensionType) dimType).getEnumName()); if (!Files.exists(dimPath.resolve(world.getProperties().getWorldName()))) { try { Files.createDirectories(rootConfigPath.resolve(dimType.getId()).resolve(world.getName())); } catch (IOException e) { e.printStackTrace(); } } DataStore.dimensionConfigMap.put(world.getProperties().getUniqueId(), new GriefPreventionConfig<DimensionConfig>(Type.DIMENSION, dimPath.resolve("dimension.conf"))); DataStore.worldConfigMap.put(world.getProperties().getUniqueId(), new GriefPreventionConfig<>( Type.WORLD, dimPath.resolve(world.getProperties().getWorldName()).resolve("world.conf"))); // refresh player data final GPClaimManager claimManager = GriefPreventionPlugin.instance.dataStore .getClaimWorldManager(world.getProperties()); for (GPPlayerData playerData : claimManager.getPlayerDataMap().values()) { if (playerData.playerID.equals(WORLD_USER_UUID) || playerData.playerID.equals(ADMIN_USER_UUID) || playerData.playerID.equals(PUBLIC_UUID)) { continue; } playerData.refreshPlayerOptions(); } // refresh default permissions this.dataStore.setupDefaultPermissions(world); } GPBlacklists.populateBlacklistStatus(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.elasticwarehouse.core.graphite.RRDManager.java
public boolean addValue(long t, LinkedList<AtrrValue> attval /*LinkedList<String> attrs, LinkedList<Double> factors*/) throws IOException, ParseException { Sample sample = rrdDb_.createSample(); sample.setTime(t);/*w ww.j a v a2s . co m*/ //int pos =0; for (AtrrValue att : attval) { //Double factor = factors.get(pos); String attrkey = transformSourceName(att.key_); if (att.value_ != Double.NaN) { boolean retryInsert = false; try { sample.setValue(attrkey, att.value_); } catch (java.lang.IllegalArgumentException e) { if (this.readOnly_) { EWLogger.logerror(e); LOGGER.error("Cannot save performance counter in " + rrDbBaseFilename_ + ": " + attrkey + " -> " + att.value_ + ". " + e.getMessage()); } else { LOGGER.info("Cannot save performance counter in " + rrDbBaseFilename_ + ": " + attrkey + " -> " + att.value_ + ". Trying to expand RRD file"); retryInsert = true; } } if (retryInsert && this.readOnly_ == false /*check readOnly_ value for double check, if adding, then alwatys whould be false */ ) { String newfilename = FileTools.generateNewFilename(this.orginalrrdPath_); LOGGER.info("Expanding " + rrDbBaseFilename_ + " RRD as new file: " + newfilename); LinkedList<String> customattributes = new LinkedList<String>(); customattributes.add(attrkey); if (expandRRDFile(tmpFolder_, rrdPath_, customattributes, newfilename)) { Dispose(); rrdPath_ = newfilename; try { reopenfile(); sample = rrdDb_.createSample(); sample.setTime(t); sample.setValue(attrkey, att.value_); } catch (DDRFileNotFoundException e) { LOGGER.error("Cannot reopen RRD file " + rrdPath_ + " after expansion"); EWLogger.logerror(e); e.printStackTrace(); } } } } } //logger.debug(sample.dump()); try { sample.update(); return true; } catch (IllegalArgumentException e) { EWLogger.logerror(e); e.printStackTrace(); return false; } }
From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java
/** * Called after audio format service processes the url and gets a streaming media url from it (if it was a playlist or something) * @param url//w w w.ja v a 2 s . com */ private void playUrl(String url) { if (LOCAL_LOGD) log("playUrl " + url, "d"); if (!mCurrentPlayerState.equals(ServiceRadioPlayer.STATE_INITIALIZING)) { if (LOCAL_LOGV) log("incorrect state to play url", "v"); return; } this.stopAndReleasePlayer(mMediaPlayer); this.mMediaPlayer = new MediaPlayer(); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mCurrentPlayerState = ServiceRadioPlayer.STATE_PREPARING; //get playlist data AsyncTaskPlaylist playlist = new AsyncTaskPlaylist(); playlist.execute(mUrl); if (LOCAL_LOGV) log("get metadata", "v"); if (!mMetadataRunnable.isRunning()) { mMetadataRunnable.init(); } //play url try { //str += mUrl; if (LOCAL_LOGV) log("setting datasource for '" + mTitle + "' at '" + url + "'", "v"); mMediaPlayer.setDataSource(url); initializePlayer(mMediaPlayer); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block log("IllegalArgumentException, setting data source failed", "e"); if (LOCAL_LOGV) e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block log("SecurityException, setting data source failed", "e"); if (LOCAL_LOGV) e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block log("IllegalStateException, setting data source failed", "e"); if (LOCAL_LOGV) e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block //TODO handle this somehow, let user know log("IOException, setting data source failed", "e"); if (LOCAL_LOGV) e.printStackTrace(); } mMediaPlayer.prepareAsync(); // might take long! (for buffering, etc) if (LOCAL_LOGV) log("preparing async", "v"); }
From source file:nz.net.catalyst.MaharaDroid.upload.http.RestClient.java
public static JSONObject CallFunction(String url, String[] paramNames, String[] paramVals, Context context) { JSONObject json = new JSONObject(); SchemeRegistry supportedSchemes = new SchemeRegistry(); SSLSocketFactory sf = getSocketFactory(DEBUG); // TODO we make assumptions about ports. supportedSchemes.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); supportedSchemes.register(new Scheme("https", sf, 443)); HttpParams http_params = new BasicHttpParams(); ClientConnectionManager ccm = new ThreadSafeClientConnManager(http_params, supportedSchemes); // HttpParams http_params = httpclient.getParams(); http_params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpConnectionParams.setConnectionTimeout(http_params, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(http_params, CONNECTION_TIMEOUT); DefaultHttpClient httpclient = new DefaultHttpClient(ccm, http_params); if (paramNames == null) { paramNames = new String[0]; }//from w w w . ja va2 s. c om if (paramVals == null) { paramVals = new String[0]; } if (paramNames.length != paramVals.length) { Log.w(TAG, "Incompatible number of param names and values, bailing on upload!"); return null; } SortedMap<String, String> sig_params = new TreeMap<String, String>(); HttpResponse response = null; HttpPost httppost = null; Log.d(TAG, "HTTP POST URL: " + url); try { httppost = new HttpPost(url); } catch (IllegalArgumentException e) { try { json.put("fail", e.getMessage()); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } return json; } try { File file = null; // If this is a POST call, then it is a file upload. Check to see if // a // filename is given, and if so, open that file. // Get the title of the photo being uploaded so we can pass it into // the // MultipartEntityMonitored class to be broadcast for progress // updates. String title = ""; for (int i = 0; i < paramNames.length; ++i) { if (paramNames[i].equals("title")) { title = paramVals[i]; } else if (paramNames[i].equals("filename")) { file = new File(paramVals[i]); continue; } sig_params.put(paramNames[i], paramVals[i]); } MultipartEntityMonitored mp_entity = new MultipartEntityMonitored(context, title); if (file != null) { mp_entity.addPart("userfile", new FileBody(file)); } for (Map.Entry<String, String> entry : sig_params.entrySet()) { mp_entity.addPart(entry.getKey(), new StringBody(entry.getValue())); } httppost.setEntity(mp_entity); response = httpclient.execute(httppost); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { String content = convertStreamToString(resEntity.getContent()); if (response.getStatusLine().getStatusCode() == 200) { try { json = new JSONObject(content.toString()); } catch (JSONException e1) { Log.w(TAG, "Response 200 received but invalid JSON."); json.put("fail", e1.getMessage()); if (DEBUG) Log.d(TAG, "HTTP POST returned status code: " + response.getStatusLine()); } } else { Log.w(TAG, "File upload failed with response code:" + response.getStatusLine().getStatusCode()); json.put("fail", response.getStatusLine().getReasonPhrase()); if (DEBUG) Log.d(TAG, "HTTP POST returned status code: " + response.getStatusLine()); } } else { Log.w(TAG, "Response does not contain a valid HTTP entity."); if (DEBUG) Log.d(TAG, "HTTP POST returned status code: " + response.getStatusLine()); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { try { json.put("fail", e.getMessage()); } catch (JSONException e1) { } e.printStackTrace(); } catch (IllegalStateException e) { try { json.put("fail", e.getMessage()); } catch (JSONException e1) { } e.printStackTrace(); } catch (IllegalArgumentException e) { try { json.put("fail", e.getMessage()); } catch (JSONException e1) { } e.printStackTrace(); } catch (JSONException e) { } httpclient.getConnectionManager().shutdown(); return json; }
From source file:jdbc.pool.JDBCPoolTestCase.java
public void testGetInstanceStringFile1() { System.out.println("testGetInstanceStringFile1 Start"); try {/* www. j ava 2s . c o m*/ try { CConnectionPoolManager.getInstance(); System.out.println("Instance is created. WRONG"); } catch (IllegalArgumentException e) { System.out.println("Instance is not created. Alright"); } CConnectionPoolManager manager = CConnectionPoolManager.getInstance( "C:/Documents and Settings/STG/workspace/jdbcpool/config/log4j.properties", new File( "C:/Documents and Settings/STG/workspace/jdbcpool/config/pool1245645558888.properties")); System.out.println("It came here Kedar in trouble" + manager); fail("getInstance(invalid data) was supposed to throw Configuration exception but did not."); } catch (ConfigurationException e) { e.printStackTrace(); assertTrue("Caught ConfigurationException", true); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testGetInstanceStringFile1 end"); }