List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:org.noorganization.instalist.server.api.UnitResource.java
/** * Returns the unit.//from www. ja va 2s .co m * @param _groupId The croup containing the requested unit. * @param _unitUUID The uuid of the requested unit. */ @GET @TokenSecured @Path("{unituuid}") @Produces({ "application/json" }) public Response getUnit(@PathParam("groupid") int _groupId, @PathParam("unituuid") String _unitUUID) throws Exception { try { UUID toFind; try { toFind = UUID.fromString(_unitUUID); } catch (IllegalArgumentException _e) { return ResponseFactory.generateBadRequest(CommonEntity.INVALID_UUID); } EntityManager manager = DatabaseHelper.getInstance().getManager(); IUnitController unitController = ControllerFactory.getUnitController(manager); DeviceGroup group = manager.find(DeviceGroup.class, _groupId); Unit resultUnit = unitController.findByGroupAndUUID(group, toFind); if (resultUnit == null) { if (unitController.findDeletedByGroupAndUUID(group, toFind) == null) { manager.close(); return ResponseFactory .generateNotFound(new Error().withMessage("The requested " + "unit was not found.")); } manager.close(); return ResponseFactory .generateGone(new Error().withMessage("The requested unit has " + "been deleted.")); } manager.close(); UnitInfo rtn = new UnitInfo().withDeleted(false); rtn.setName(resultUnit.getName()); rtn.setUUID(resultUnit.getUUID()); rtn.setLastChanged(Date.from(resultUnit.getUpdated())); return ResponseFactory.generateOK(rtn); } catch (Exception _e) { _e.printStackTrace(); throw _e; } }
From source file:com.klinker.android.twitter.activities.drawer_activities.DrawerActivity.java
public void cancelTeslaUnread() { new Thread(new Runnable() { @Override//ww w . java2s.c o m public void run() { try { ContentValues cv = new ContentValues(); cv.put("tag", "com.klinker.android.twitter/com.klinker.android.twitter.ui.MainActivity"); cv.put("count", 0); // back to zero context.getContentResolver() .insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (IllegalArgumentException ex) { /* Fine, TeslaUnread is not installed. */ } catch (Exception ex) { /* Some other error, possibly because the format of the ContentValues are incorrect. Log but do not crash over this. */ ex.printStackTrace(); } } }).start(); }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
@Override protected void onDestroy() { super.onDestroy(); Log.v(TAG, "exiting HCI Debugger app"); if (mDialog != null) { mDialog.dismiss();/*from w w w . j a va 2s . c om*/ } if (service != null) { service.stopHciLogStream(); } try { if (bound) { // unregister receiver or you will have strong exception unbindService(mServiceConnection); bound = false; } } catch (IllegalArgumentException e) { e.printStackTrace(); } }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
/** * Activate/Desactivate snoop file log/*www . j a v a2s . co m*/ * * @param state true if snoop file log is activated, false elsewhere */ public void configSnoopFile(boolean state) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); Method[] adapterMethods = adapter.getClass().getDeclaredMethods(); for (Method method : adapterMethods) { if (method.getName().equals("configHciSnoopLog")) { Log.v(TAG, "activating snoop file log"); try { boolean ret = (boolean) method.invoke(adapter, state); Log.v(TAG, "configSnoop return with state " + ret); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }
From source file:com.chaqianma.jd.fragment.CompanyInfoFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case REQUEST_SDK_IMGS: if (data != null && data.getData() != null) { Uri imgUri = data.getData(); ContentResolver resolver = getActivity().getContentResolver(); String[] pojo = { MediaStore.Images.Media.DATA }; Cursor cursor = null; try { cursor = resolver.query(imgUri, pojo, null, null, null); if (cursor != null && cursor.getCount() > 0) { int colunm_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); new Thread(new BaseFragment.ImgRunable(cursor.getString(colunm_index), Constants.BUSINESS_INFO, fileType, selCompanyIdxTag, new UpdateUIHandler())) .start(); } else { JDToast.showLongText(getActivity(), ""); }//from w w w .ja v a 2 s . c om } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } } break; case REQUEST_TAKE_PHOTO: new Thread(new BaseFragment.ImgRunable(Constants.TEMPPATH, Constants.BUSINESS_INFO, fileType, selCompanyIdxTag, new UpdateUIHandler())).start(); break; default: break; } } }
From source file:freed.cam.apis.camera2.modules.VideoModuleApi2.java
@TargetApi(VERSION_CODES.LOLLIPOP) private void startPreviewVideo() { recordingFile = new File(cameraUiWrapper.getActivityInterface().getStorageHandler() .getNewFilePath(appSettingsManager.GetWriteExternal(), ".mp4")); mediaRecorder = new MediaRecorder(); mediaRecorder.reset();/*from w ww . j a v a 2 s . co m*/ mediaRecorder.setMaxFileSize(3037822976L); //~2.8 gigabyte mediaRecorder.setMaxDuration(7200000); //2hours mediaRecorder.setOnErrorListener(new OnErrorListener() { @Override public void onError(MediaRecorder mr, int what, int extra) { Log.d(TAG, "error MediaRecorder:" + what + "extra:" + extra); cameraUiWrapper.GetModuleHandler() .onRecorderstateChanged(I_RecorderStateChanged.STATUS_RECORDING_STOP); changeCaptureState(ModuleHandlerAbstract.CaptureStates.video_recording_stop); } }); mediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() { @Override public void onInfo(MediaRecorder mr, int what, int extra) { if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) { recordnextFile(mr); } else if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) { recordnextFile(mr); } } }); if (cameraUiWrapper.GetAppSettingsManager().getApiString(AppSettingsManager.SETTING_LOCATION) .equals(KEYS.ON)) { Location location = cameraUiWrapper.getActivityInterface().getLocationHandler().getCurrentLocation(); if (location != null) mediaRecorder.setLocation((float) location.getLatitude(), (float) location.getLongitude()); } switch (currentVideoProfile.Mode) { case Normal: case Highspeed: if (currentVideoProfile.isAudioActive) mediaRecorder.setAudioSource(AudioSource.CAMCORDER); break; case Timelapse: break; } mediaRecorder.setVideoSource(VideoSource.SURFACE); mediaRecorder.setOutputFormat(OutputFormat.MPEG_4); setRecorderFilePath(); mediaRecorder.setVideoEncodingBitRate(currentVideoProfile.videoBitRate); try { cameraHolder.SetParameterRepeating(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(currentVideoProfile.videoFrameRate, currentVideoProfile.videoFrameRate)); } catch (Exception e) { e.printStackTrace(); } // if(currentVideoProfile.Mode == VideoMediaProfile.VideoMode.SlowMO) // int SlowFactor = currentVideoProfile.videoFrameRate /30; if (currentVideoProfile.videoFrameRate == 120 && currentVideoProfile.videoFrameWidth == 1920) mediaRecorder.setVideoFrameRate(60); else mediaRecorder.setVideoFrameRate(currentVideoProfile.videoFrameRate); /*setCaptureRate Added in API level 11 void setCaptureRate (double fps) Set video frame capture rate. This can be used to set a different video frame capture rate than the recorded video's playback rate. !!!!!! This method also sets the recording mode to time lapse.!!!!! In time lapse video recording, only video is recorded. Audio related parameters are ignored when a time lapse recording session starts, if an application sets them.*/ //mediaRecorder.setCaptureRate((double)currentVideoProfile.videoFrameRate); mediaRecorder.setVideoSize(currentVideoProfile.videoFrameWidth, currentVideoProfile.videoFrameHeight); try { mediaRecorder.setVideoEncoder(currentVideoProfile.videoCodec); } catch (IllegalArgumentException ex) { mediaRecorder.reset(); cameraUiWrapper.GetCameraHolder().SendUIMessage("VideoCodec not Supported"); } switch (currentVideoProfile.Mode) { case Normal: case Highspeed: if (currentVideoProfile.isAudioActive) { try { mediaRecorder.setAudioEncoder(currentVideoProfile.audioCodec); } catch (IllegalArgumentException ex) { mediaRecorder.reset(); cameraUiWrapper.GetCameraHolder().SendUIMessage("AudioCodec not Supported"); } mediaRecorder.setAudioChannels(currentVideoProfile.audioChannels); mediaRecorder.setAudioEncodingBitRate(currentVideoProfile.audioBitRate); mediaRecorder.setAudioSamplingRate(currentVideoProfile.audioSampleRate); } break; case Timelapse: float frame = 30; if (!appSettingsManager.getApiString(AppSettingsManager.TIMELAPSEFRAME).equals("")) frame = Float.parseFloat( appSettingsManager.getApiString(AppSettingsManager.TIMELAPSEFRAME).replace(",", ".")); else appSettingsManager.setApiString(AppSettingsManager.TIMELAPSEFRAME, "" + frame); mediaRecorder.setCaptureRate(frame); break; } try { mediaRecorder.prepare(); } catch (IOException ex) { ex.printStackTrace(); cameraUiWrapper.GetModuleHandler().onRecorderstateChanged(I_RecorderStateChanged.STATUS_RECORDING_STOP); changeCaptureState(ModuleHandlerAbstract.CaptureStates.video_recording_stop); return; } recorderSurface = mediaRecorder.getSurface(); cameraHolder.CaptureSessionH.AddSurface(recorderSurface, true); if (currentVideoProfile.Mode != VideoMediaProfile.VideoMode.Highspeed) cameraHolder.CaptureSessionH.CreateCaptureSession(previewrdy); else cameraHolder.CaptureSessionH.CreateHighSpeedCaptureSession(previewrdy); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public void testGetInstanceStringFile2() { logger.debug("testGetInstanceStringFile2 Start"); try {//from www . j a v a 2 s . c o m CConnectionPoolManager manager = CConnectionPoolManager.getInstance(null, new File(this.getClass().getClassLoader().getResource("config/pool.properties").getFile())); assertNotNull("Instance not null", manager); assertNotNull("Ascertain CConnectionPoolManager.getInstance()also returns not null", CConnectionPoolManager.getInstance()); assertTrue("ascertain CConnectionPoolManager.getInstance() == manager", manager.hashCode() == CConnectionPoolManager.getInstance().hashCode()); manager.destroy(true); testGetInstanceNull(); } catch (IllegalArgumentException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } 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"); } logger.debug("testGetInstanceStringFile2 end"); }
From source file:com.android.wako.net.AsyncHttpPost.java
public boolean process() { try {/*from w w w .jav a2 s . c o m*/ // LogUtil.d(Tag, "---process---url="+url+"?"+getParames()); request = new HttpPost(url); if (Constants.isGzip) { request.addHeader("Accept-Encoding", "gzip"); } else { request.addHeader("Accept-Encoding", "default"); } request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); // LogUtil.d(AsyncHttpPost.class.getName(), // "AsyncHttpPost request to url :" + url); if (parameter != null && parameter.size() > 0) { List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>(); for (RequestParameter p : parameter) { list.add(new BasicNameValuePair(p.getName(), p.getValue())); } ((HttpPost) request).setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); } httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout); httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout); HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { InputStream is = response.getEntity().getContent(); BufferedInputStream bis = new BufferedInputStream(is); bis.mark(2); // ?? byte[] header = new byte[2]; int result = bis.read(header); // reset?? bis.reset(); // ?GZIP? int headerData = getShort(header); // Gzip ? ? 0x1f8b if (result != -1 && headerData == 0x1f8b) { LogUtil.d("HttpTask", " use GZIPInputStream "); is = new GZIPInputStream(bis); } else { LogUtil.d("HttpTask", " not use GZIPInputStream"); is = bis; } InputStreamReader reader = new InputStreamReader(is, "utf-8"); char[] data = new char[100]; int readSize; StringBuffer sb = new StringBuffer(); while ((readSize = reader.read(data)) > 0) { sb.append(data, 0, readSize); } ret = sb.toString(); bis.close(); reader.close(); return true; } else { mRetStatus = ResStatus.Error_Code; RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "??,??" + statusCode); // ret = ErrorUtil.errorJson("ERROR.HTTP.001", // exception.getMessage()); } LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " finished !"); } catch (IllegalArgumentException e) { mRetStatus = ResStatus.Error_IllegalArgument; // RequestException exception = new RequestException( // RequestException.IO_EXCEPTION, Constants.ERROR_MESSAGE); // ret = ErrorUtil.errorJson("ERROR.HTTP.002", exception.getMessage()); LogUtil.d(AsyncHttpGet.class.getName(), "AsyncHttpPost request to url :" + url + " onFail " + e.getMessage()); } catch (org.apache.http.conn.ConnectTimeoutException e) { mRetStatus = ResStatus.Error_Connect_Timeout; // RequestException exception = new RequestException( // RequestException.SOCKET_TIMEOUT_EXCEPTION, Constants.ERROR_MESSAGE); // ret = ErrorUtil.errorJson("ERROR.HTTP.003", exception.getMessage()); LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " onFail " + e.getMessage()); } catch (java.net.SocketTimeoutException e) { mRetStatus = ResStatus.Error_Socket_Timeout; // RequestException exception = new RequestException( // RequestException.SOCKET_TIMEOUT_EXCEPTION, Constants.ERROR_MESSAGE); // ret = ErrorUtil.errorJson("ERROR.HTTP.004", exception.getMessage()); LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " onFail " + e.getMessage()); } catch (UnsupportedEncodingException e) { mRetStatus = ResStatus.Error_Unsupport_Encoding; e.printStackTrace(); // RequestException exception = new RequestException( // RequestException.UNSUPPORTED_ENCODEING_EXCEPTION, "?"); // ret = ErrorUtil.errorJson("ERROR.HTTP.005", exception.getMessage()); LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " UnsupportedEncodingException " + e.getMessage()); } catch (org.apache.http.conn.HttpHostConnectException e) { mRetStatus = ResStatus.Error_HttpHostConnect; e.printStackTrace(); // RequestException exception = new RequestException( // RequestException.CONNECT_EXCEPTION, ""); // ret = ErrorUtil.errorJson("ERROR.HTTP.006", exception.getMessage()); LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " HttpHostConnectException " + e.getMessage()); } catch (ClientProtocolException e) { mRetStatus = ResStatus.Error_Client_Protocol; e.printStackTrace(); // RequestException exception = new RequestException( // RequestException.CLIENT_PROTOL_EXCEPTION, "??"); // ret = ErrorUtil.errorJson("ERROR.HTTP.007", exception.getMessage()); LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " ClientProtocolException " + e.getMessage()); } catch (IOException e) { mRetStatus = ResStatus.Error_IOException; // RequestException exception = new RequestException( // RequestException.IO_EXCEPTION, "??"); // ret = ErrorUtil.errorJson("ERROR.HTTP.008", exception.getMessage()); e.printStackTrace(); LogUtil.d(AsyncHttpPost.class.getName(), "AsyncHttpPost request to url :" + url + " IOException " + e.getMessage()); } catch (Exception e) { mRetStatus = ResStatus.Error_IOException; e.printStackTrace(); } return false; }
From source file:com.chaqianma.jd.fragment.PersonalAssetsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case REQUEST_SDK_IMGS: if (data != null && data.getData() != null) { Uri imgUri = data.getData(); ContentResolver resolver = getActivity().getContentResolver(); String[] pojo = { MediaStore.Images.Media.DATA }; Cursor cursor = null; try { cursor = resolver.query(imgUri, pojo, null, null, null); if (cursor != null && cursor.getCount() > 0) { int colunm_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); new Thread(new BaseFragment.ImgRunable(cursor.getString(colunm_index), fileType, selIdxTag, new UpdateUIHandler())).start(); //mHandler.post(new ImgRunable(cursor.getString(colunm_index))); } else { JDToast.showLongText(getActivity(), ""); }//w w w .ja va 2 s .c o m } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } } break; case REQUEST_TAKE_PHOTO: // mHandler.post(mRunnable); new Thread( new BaseFragment.ImgRunable(Constants.TEMPPATH, fileType, selIdxTag, new UpdateUIHandler())) .start(); break; default: break; } } }
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testValidateBadRecordsActionWithProperValue() throws IOException { String path = "./testValidateBadRecordsActionValue"; 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_ACTION", "FAIL"); try {//from ww w. ja v a 2s . c o m 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)); } }