List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:com.ricemap.spateDB.operations.RangeQuery.java
/** * Performs a range query using MapReduce * /*from w w w. j a v a 2 s . com*/ * @param fs * @param inputFile * @param queryRange * @param shape * @param output * @return * @throws IOException */ public static long rangeQueryMapReduce(FileSystem fs, Path inputFile, Path userOutputPath, Shape queryShape, Shape shape, boolean overwrite, boolean background, QueryInput query) throws IOException { JobConf job = new JobConf(FileMBR.class); FileSystem outFs = inputFile.getFileSystem(job); Path outputPath = userOutputPath; if (outputPath == null) { do { outputPath = new Path( inputFile.toUri().getPath() + ".rangequery_" + (int) (Math.random() * 1000000)); } while (outFs.exists(outputPath)); } else { if (outFs.exists(outputPath)) { if (overwrite) { outFs.delete(outputPath, true); } else { throw new RuntimeException("Output path already exists and -overwrite flag is not set"); } } } job.setJobName("RangeQuery"); job.setClass(SpatialSite.FilterClass, RangeFilter.class, BlockFilter.class); RangeFilter.setQueryRange(job, queryShape); // Set query range for // filter ClusterStatus clusterStatus = new JobClient(job).getClusterStatus(); job.setNumMapTasks(clusterStatus.getMaxMapTasks() * 5); job.setNumReduceTasks(3); // Decide which map function to use depending on how blocks are indexed // And also which input format to use if (SpatialSite.isRTree(fs, inputFile)) { // RTree indexed file LOG.info("Searching an RTree indexed file"); job.setInputFormat(RTreeInputFormat.class); } else { // A file with no local index LOG.info("Searching a non local-indexed file"); job.setInputFormat(ShapeInputFormat.class); } GlobalIndex<Partition> gIndex = SpatialSite.getGlobalIndex(fs, inputFile); // if (gIndex != null && gIndex.isReplicated()){ // job.setMapperClass(RangeQueryMap.class); Class<?> OutputKey = NullWritable.class; try { Class<?> c = shape.getClass(); Field f = c.getDeclaredField(query.field); f.setAccessible(true); if (f.getType().equals(Integer.TYPE)) { OutputKey = IntWritable.class; } else if (f.getType().equals(Double.TYPE)) { OutputKey = DoubleWritable.class; } else if (f.getType().equals(Long.TYPE)) { OutputKey = LongWritable.class; } } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } job.setMapOutputKeyClass(OutputKey); switch (query.type) { case Distinct: job.setMapperClass(DistinctQueryMap.class); job.setReducerClass(DistinctQueryReduce.class); job.setMapOutputValueClass(NullWritable.class); break; case Distribution: job.setMapperClass(DistributionQueryMap.class); job.setReducerClass(DistributionQueryReduce.class); job.setMapOutputValueClass(IntWritable.class); break; default: break; } // } // else // job.setMapperClass(RangeQueryMapNoDupAvoidance.class); // Set query range for the map function job.set(QUERY_SHAPE_CLASS, queryShape.getClass().getName()); job.set(QUERY_SHAPE, queryShape.toText(new Text()).toString()); job.set(QUERY_FIELD, query.field); // Set shape class for the SpatialInputFormat SpatialSite.setShapeClass(job, shape.getClass()); job.setOutputFormat(TextOutputFormat.class); ShapeInputFormat.setInputPaths(job, inputFile); TextOutputFormat.setOutputPath(job, outputPath); // Submit the job if (!background) { RunningJob runningJob = JobClient.runJob(job); Counters counters = runningJob.getCounters(); Counter outputRecordCounter = counters.findCounter(Task.Counter.MAP_OUTPUT_RECORDS); final long resultCount = outputRecordCounter.getValue(); // If outputPath not set by user, automatically delete it if (userOutputPath == null) outFs.delete(outputPath, true); return resultCount; } else { JobClient jc = new JobClient(job); lastRunningJob = jc.submitJob(job); return -1; } }
From source file:com.cottsoft.thrift.framework.server.RunServer.java
@Override public void run() { try {//from ww w .j a v a 2 s. c o m new ClassPathXmlApplicationContext(new String[] { "config/app.xml" }); } catch (SecurityException e) { logger.debug(e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { logger.debug(e.getMessage()); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.sakaiproject.poll.tool.params.PermissionAction.java
public String setPermissions() { if ("cancel".equals(submissionStatus)) return "cancel"; LOG.info("Seting permissions"); if (perms == null) LOG.error("My perms Map is null"); else {/*from w ww . j a v a2 s . co m*/ try { externalLogic.setToolPermissions(perms, externalLogic.getCurrentLocationReference()); } catch (SecurityException e) { e.printStackTrace(); return "error"; } catch (IllegalArgumentException e) { e.printStackTrace(); return "error"; } } return "Success"; }
From source file:org.opendatakit.common.android.utilities.Base64Wrapper.java
public byte[] decode(String base64String) { Class<?>[] argClassList = new Class[] { String.class, int.class }; Object o;//w w w .j ava 2 s. c o m try { Method m = base64.getDeclaredMethod("decode", argClassList); Object[] argList = new Object[] { base64String, FLAGS }; o = m.invoke(null, argList); } catch (SecurityException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (InvocationTargetException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } return (byte[]) o; }
From source file:org.opendatakit.common.android.utilities.Base64Wrapper.java
public String encodeToString(byte[] ba) { Class<?>[] argClassList = new Class[] { byte[].class, int.class }; try {//from w w w .j a va2 s . c om Method m = base64.getDeclaredMethod("encode", argClassList); Object[] argList = new Object[] { ba, FLAGS }; Object o = m.invoke(null, argList); byte[] outArray = (byte[]) o; String s = new String(outArray, CharEncoding.UTF_8); return s; } catch (SecurityException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (InvocationTargetException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } }
From source file:org.opendatakit.services.utilities.Base64Wrapper.java
public String encodeToString(byte[] ba) { Class<?>[] argClassList = new Class[] { byte[].class, int.class }; try {//from w w w . j a v a 2 s.co m Method m = base64.getDeclaredMethod("encode", argClassList); Object[] argList = new Object[] { ba, FLAGS }; Object o = m.invoke(null, argList); byte[] outArray = (byte[]) o; String s = new String(outArray, CharEncoding.UTF_8); return s; } catch (SecurityException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (IllegalAccessException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (InvocationTargetException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (UnsupportedEncodingException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } }
From source file:org.sglj.service.rmi.server.NotificationServiceStub.java
protected void callNotificationMethod(T[] recipients, String methodName, Object... args) throws ServiceReflectionCallException { Class<?>[] paramTypes = new Class<?>[args == null ? 0 : args.length]; if (args != null) { for (int i = 0; i < paramTypes.length; ++i) { paramTypes[i] = args[i].getClass(); }//from ww w. ja va2 s . c om } Method method; try { method = MethodUtils.getMatchingAccessibleMethod(this.getClass(), methodName, paramTypes); } catch (SecurityException e) { e.printStackTrace(); throw new ServiceReflectionCallException(e); } if (!this.remoteMethods.contains(method)) { throw new ServiceReflectionCallException("No such method"); } this.sender.sendNotification(recipients, new RemoteCallRequest(getId(), methodName, args)); }
From source file:com.irccloud.android.GCMIntentService.java
public static void scheduleRegisterTimer(int delay) { final int retrydelay = (delay < 500) ? 500 : delay; GCMTimer.schedule(new TimerTask() { @Override//from w ww .ja v a2 s. co m public void run() { if (!IRCCloudApplication.getInstance().getApplicationContext().getSharedPreferences("prefs", 0) .contains("session_key")) { return; } boolean success = false; if (getRegistrationId(IRCCloudApplication.getInstance().getApplicationContext()).length() == 0) { try { String oldRegId = IRCCloudApplication.getInstance().getApplicationContext() .getSharedPreferences("prefs", 0).getString("gcm_reg_id", ""); String regId = GoogleCloudMessaging .getInstance(IRCCloudApplication.getInstance().getApplicationContext()) .register(BuildConfig.GCM_ID); int appVersion = getAppVersion(); Log.i("IRCCloud", "Saving regId on app version " + appVersion); SharedPreferences.Editor editor = IRCCloudApplication.getInstance().getApplicationContext() .getSharedPreferences("prefs", 0).edit(); editor.putString("gcm_reg_id", regId); editor.putInt("gcm_app_version", appVersion); editor.putString("gcm_app_build", Build.FINGERPRINT); editor.remove("gcm_registered"); editor.commit(); if (oldRegId.length() > 0 && !oldRegId.equals(regId)) { Log.i("IRCCloud", "Unregistering old ID"); scheduleUnregisterTimer(1000, oldRegId, true); } } catch (IOException ex) { ex.printStackTrace(); Log.w("IRCCloud", "Failed to register device ID, will retry in " + ((retrydelay * 2) / 1000) + " seconds"); scheduleRegisterTimer(retrydelay * 2); return; } catch (SecurityException e) { //User has blocked GCM via AppOps return; } } Log.i("IRCCloud", "Sending GCM ID to IRCCloud"); try { JSONObject result = NetworkConnection.getInstance().registerGCM( getRegistrationId(IRCCloudApplication.getInstance().getApplicationContext()), IRCCloudApplication.getInstance().getApplicationContext() .getSharedPreferences("prefs", 0).getString("session_key", "")); if (result.has("success")) success = result.getBoolean("success"); } catch (Exception e) { e.printStackTrace(); } if (success) { SharedPreferences.Editor editor = IRCCloudApplication.getInstance().getApplicationContext() .getSharedPreferences("prefs", 0).edit(); editor.putBoolean("gcm_registered", true); editor.commit(); Log.d("IRCCloud", "Device successfully registered"); } else { Log.w("IRCCloud", "Failed to register device ID, will retry in " + ((retrydelay * 2) / 1000) + " seconds"); scheduleRegisterTimer(retrydelay * 2); } } }, delay); }
From source file:org.apache.tomcat.util.IntrospectionUtils.java
public static Object getProperty(Object o, String name) { String getter = "get" + capitalize(name); String isGetter = "is" + capitalize(name); try {/*from w w w . j a va 2 s. co m*/ Method methods[] = findMethods(o.getClass()); Method getPropertyMethod = null; // First, the ideal case - a getFoo() method for (int i = 0; i < methods.length; i++) { Class paramT[] = methods[i].getParameterTypes(); if (getter.equals(methods[i].getName()) && paramT.length == 0) { return methods[i].invoke(o, (Object[]) null); } if (isGetter.equals(methods[i].getName()) && paramT.length == 0) { return methods[i].invoke(o, (Object[]) null); } if ("getProperty".equals(methods[i].getName())) { getPropertyMethod = methods[i]; } } // Ok, no setXXX found, try a getProperty("name") if (getPropertyMethod != null) { Object params[] = new Object[1]; params[0] = name; return getPropertyMethod.invoke(o, params); } } catch (IllegalArgumentException ex2) { log.warn("IAE " + o + " " + name, ex2); } catch (SecurityException ex1) { if (dbg > 0) d("SecurityException for " + o.getClass() + " " + name + ")"); if (dbg > 1) ex1.printStackTrace(); } catch (IllegalAccessException iae) { if (dbg > 0) d("IllegalAccessException for " + o.getClass() + " " + name + ")"); if (dbg > 1) iae.printStackTrace(); } catch (InvocationTargetException ie) { if (dbg > 0) d("InvocationTargetException for " + o.getClass() + " " + name + ")"); if (dbg > 1) ie.printStackTrace(); } return null; }
From source file:com.fxforbiz.softphone.core.managers.UpdateManager.java
/** * This method handles the update process for the application. * @return Either the update is successful or not. *///from w ww. ja v a 2s. co m public boolean startUpdateProcess() { Application.getInstance().getLogger().log("Begining update...", Logger.INFO); String urlLicenceFile = Application.getInstance().getPropertyManger() .getProperty("URL_UPDATE_LICENCE_FILE"); String urlPropertiesFile = Application.getInstance().getPropertyManger() .getProperty("URL_UPDATE_PROPERTIES_FILE"); String appVersion = Application.getInstance().getPropertyManger().getProperty("APP_VERSION"); String pathLicenceFile = "Softphone_" + appVersion + "_lib/license.jar"; String pathPropertiesFile = "config.properties"; File licenceFileToRemove = new File(pathLicenceFile); File propertiesFileToRemove = new File(pathPropertiesFile); if (licenceFileToRemove.exists() == false) { Application.getInstance().getLogger().log( "licence file missing, aborting... (" + licenceFileToRemove.getAbsolutePath() + ")", Logger.CRITICAL); return false; } if (propertiesFileToRemove.exists() == false) { Application.getInstance().getLogger().log("properties file missing, aborting...", Logger.CRITICAL); return false; } try { licenceFileToRemove.delete(); propertiesFileToRemove.delete(); } catch (SecurityException se) { se.printStackTrace(); } Application.getInstance().getLogger().log("Updating licence...", Logger.INFO); this.downloadFile(urlLicenceFile, pathLicenceFile); Application.getInstance().getLogger().log("Updating config...", Logger.INFO); this.downloadFile(urlPropertiesFile, pathPropertiesFile); Application.getInstance().getLogger().log("Update successfull !", Logger.INFO); return true; }