List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:com.qi.airstat.BluetoothLeService.java
@Override public void onCreate() { try {/*from ww w . j av a 2 s .c o m*/ locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1, locationListener); } catch (SecurityException exception) { exception.printStackTrace(); } }
From source file:fr.cls.atoll.motu.processor.wps.StringList.java
public static ProcessDescriptions getDescribeProcess() { UserBase user = new UserBase(); user.setLogin("xxx"); user.setPwd("xxx"); user.setAuthenticationMode(AuthenticationMode.CAS); AuthenticationHolder.setUser(user);/* ww w. ja v a 2s .com*/ //String href = "http://localhost:8080/atoll-motuservlet/services"; String href = "http://atoll-dev.cls.fr:30080/mis-gateway-servlet/ogc"; InputStream in = null; Map<String, String> headers = new HashMap<String, String>(); try { in = Organizer.getUriAsInputStream("DescribeAll.xml"); in = WPSUtils.post(HttpUtils.STREAM, href, in, headers); // byte b[] = new byte[1024]; // // int bytesRead = 0; // if (in.markSupported()) { // in.mark(bytesRead); // } // // while ((bytesRead = in.read(b)) != -1) { // String nextLine = new String(b, 0, bytesRead); // System.out.println(nextLine); // } // // if (in.markSupported()) { // in.reset(); // } } catch (HttpException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MotuException e) { // TODO Auto-generated catch block e.printStackTrace(); } ProcessDescriptions processDescriptions = null; if (in == null) { return processDescriptions; } try { JAXBContext jc = JAXBContext.newInstance(MotuWPSProcess.WPS100_SHEMA_PACK_NAME); Unmarshaller unmarshaller = jc.createUnmarshaller(); processDescriptions = (ProcessDescriptions) unmarshaller.unmarshal(in); } catch (Exception e) { // throw new MotuException("Error in GetDescribeProcess", e); System.out.println(e.getMessage()); } if (processDescriptions == null) { // throw new // MotuException("Unable to load WPS Process Descriptions (processDescriptions is null)"); System.out.println("Unable to load WPS Process Descriptions (processDescriptions is null)"); return processDescriptions; } List<ProcessDescriptionType> processDescriptionList = processDescriptions.getProcessDescription(); for (ProcessDescriptionType processDescriptionType : processDescriptionList) { // JAXBElement<String> element = new JAXBElement<String>(new QName("Test"), String.class, "tre"); System.out.println("==================="); System.out.println(processDescriptionType.getIdentifier().getValue()); System.out.println("==================="); List<InputDescriptionType> inputDescriptionTypeList = processDescriptionType.getDataInputs().getInput(); for (InputDescriptionType inputDescriptionType : inputDescriptionTypeList) { Object inputData = null; String fieldName = ""; if (inputDescriptionType.getLiteralData() != null) { inputData = inputDescriptionType.getLiteralData(); // JAXBElement<InputDescriptionType> element = inputDescriptionType; } if (inputDescriptionType.getComplexData() != null) { inputData = inputDescriptionType.getComplexData(); } if (inputDescriptionType.getBoundingBoxData() != null) { inputData = inputDescriptionType.getBoundingBoxData(); } try { Field[] fields = DescriptionType.class.getDeclaredFields(); for (Field field : fields) { System.out.println(field.getName()); } System.out.println(DescriptionType.class.getDeclaredField("identifier") .getAnnotation(XmlElement.class).toString()); System.out.println(inputDescriptionType.getIdentifier().getCodeSpace()); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NoSuchFieldException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.print(inputDescriptionType.getIdentifier().getValue()); System.out.print(" class is '"); System.out.println(inputData.getClass().getName()); System.out.print("', XmlElement is '"); try { System.out.print(InputDescriptionType.class.getDeclaredField("complexData") .getAnnotation(XmlElement.class).toString()); // System.out.print(InputDescriptionType.class.getDeclaredField("complexData").getAnnotation(XmlElement.class).name()); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("'"); } } return processDescriptions; }
From source file:fashiome.android.fragments.MapListFragment.java
@NeedsPermission({ fashiome.android.Manifest.permission.ACCESS_FINE_LOCATION, fashiome.android.Manifest.permission.ACCESS_COARSE_LOCATION }) @Override// w ww . j a va 2 s .c om public void onConnected(Bundle bundle) { mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setNumUpdates(1); try { LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); } catch (SecurityException e) { e.printStackTrace(); } }
From source file:org.Microsoft.Telemetry.IntermediateHistoryStore.java
@Override protected void serviceInit(Configuration conf) throws Exception { try {// www . ja va 2 s . co m //Method m = originalStorage.getClass().getDeclaredMethod("serviceInit", Configuration.class); Method m = originalStorage.getClass().getMethod("serviceInit", Configuration.class); m.setAccessible(true); m.invoke(originalStorage, (Object) conf); } catch (NoSuchMethodException noSuchMethodException) { LOG.error(PATTERN_LOG_ERROR + "no Such Method Exception :", noSuchMethodException); noSuchMethodException.printStackTrace(); } catch (SecurityException securityException) { LOG.error(PATTERN_LOG_ERROR + "Security Exception :", securityException); securityException.printStackTrace(); } catch (IllegalAccessException illegalAccessException) { LOG.error(PATTERN_LOG_ERROR + "Illegal Access Exception :", illegalAccessException); illegalAccessException.printStackTrace(); } catch (IllegalArgumentException illegalArgumentException) { LOG.error(PATTERN_LOG_ERROR + "Illegal Argument Exception :", illegalArgumentException); illegalArgumentException.printStackTrace(); } catch (InvocationTargetException invocationTargetException) { Throwable cause = invocationTargetException.getCause(); LOG.error(PATTERN_LOG_ERROR + "Invocation Target Exception failed because of:" + cause.getMessage(), invocationTargetException); invocationTargetException.printStackTrace(); } }
From source file:fashiome.android.fragments.MapListFragment.java
@NeedsPermission({ fashiome.android.Manifest.permission.ACCESS_FINE_LOCATION, fashiome.android.Manifest.permission.ACCESS_COARSE_LOCATION }) void getMyLocation() { if (mMap != null) { // Now that map has loaded, let's get our location! try {/* w ww. j a v a 2s. co m*/ mMap.setMyLocationEnabled(true); } catch (SecurityException e) { e.printStackTrace(); } mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); connectClient(); } }
From source file:com.qi.airstat.BluetoothLeService.java
/** * Connects to the GATT server hosted on the Bluetooth LE device. * * @param address The device address of the destination device. * * @return Return true if the connection is initiated successfully. The connection result * is reported asynchronously through the * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)} * callback./* ww w . j a v a 2 s . c o m*/ */ public boolean connect(final String address) { if (mBluetoothAdapter == null || address == null) { Log.w(TAG, "BluetoothAdapter not initialized or unspecified address."); BluetoothState.isBLEConnected(false); return false; } // Previously connected device. Try to reconnect. if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null) { Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection."); if (mBluetoothGatt.connect()) { mConnectionState = STATE_CONNECTING; return true; } else { BluetoothState.isBLEConnected(false); return false; } } final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); if (device == null) { Log.w(TAG, "Device not found. Unable to connect."); BluetoothState.isBLEConnected(false); return false; } // We want to directly connect to the device, so we are setting the autoConnect // parameter to false. mBluetoothGatt = device.connectGatt(this, false, mGattCallback); Log.d(TAG, "Trying to create a new connection."); mBluetoothDeviceAddress = address; mConnectionState = STATE_CONNECTING; Constants.MAC_POLAR = mBluetoothDeviceAddress; try { Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); latitude = location.getLatitude(); longitude = location.getLongitude(); } catch (SecurityException exception) { exception.printStackTrace(); } JSONObject jsonObject = new JSONObject(); try { jsonObject.put("userID", Constants.UID); jsonObject.put("conCreationTime", new SimpleDateFormat("yyMMddHHmmss").format(new java.util.Date())); jsonObject.put("flagValidCon", 1); jsonObject.put("devMAC", "x'" + Constants.MAC_POLAR.replaceAll(":", "") + "'"); jsonObject.put("devType", Constants.DEVICE_TYPE_POLAR); jsonObject.put("devPortability", 0x01); jsonObject.put("latitude", "x'" + latitude); jsonObject.put("longitude", "x'" + longitude); } catch (JSONException exception) { exception.printStackTrace(); } HttpService httpService = new HttpService(); String res = httpService.executeConn(null, "POST", "http://teamc-iot.calit2.net/IOT/public/deviceReg", jsonObject); try { JSONObject resJson; resJson = new JSONObject(res); Log.d("BLEService", "DevReg sent, response was " + res); if (resJson.getInt("status") == 0) { return true; } else { mConnectionState = STATE_DISCONNECTED; Constants.MAC_POLAR = null; BluetoothState.isBLEConnected(false); return false; } } catch (JSONException exception) { exception.printStackTrace(); return false; } }
From source file:com.qi.airstat.BluetoothLeService.java
private void broadcastUpdate(final String action, final BluetoothGattCharacteristic characteristic) { final Intent intent = new Intent(action); int signal = 0; // This is special handling for the Heart Rate Measurement profile. Data parsing is // carried out as per profile specifications: // http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) { int flag = characteristic.getProperties(); int format = -1; if ((flag & 0x01) != 0) { format = BluetoothGattCharacteristic.FORMAT_UINT16; Log.d(TAG, "Heart rate format UINT16."); } else {/* www . j a v a 2 s . co m*/ format = BluetoothGattCharacteristic.FORMAT_UINT8; Log.d(TAG, "Heart rate format UINT8."); } final int heartRate = characteristic.getIntValue(format, 1); signal = heartRate; Log.d(TAG, String.format("Received heart rate: %d", heartRate)); intent.putExtra(EXTRA_DATA, String.valueOf(heartRate)); } else { // For all other profiles, writes the data formatted in HEX. final byte[] data = characteristic.getValue(); if (data != null && data.length > 0) { final StringBuilder stringBuilder = new StringBuilder(data.length); for (byte byteChar : data) stringBuilder.append(String.format("%02X ", byteChar)); intent.putExtra(EXTRA_DATA, new String(data) + "\n" + stringBuilder.toString()); signal = Integer.parseInt(new String(data)); } } DatabaseManager databaseManager = new DatabaseManager(BluetoothLeService.this); SQLiteDatabase database = databaseManager.getWritableDatabase(); ContentValues values = new ContentValues(); String date = new SimpleDateFormat("yyMMddHHmmss").format(new java.util.Date()); values.put(Constants.DATABASE_COMMON_COLUMN_TIME_STAMP, date); values.put(Constants.DATABASE_HEART_RATE_COLUMN_HEART_RATE, signal); database.insert(Constants.DATABASE_HEART_RATE_TABLE, null, values); database.close(); try { Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); latitude = location.getLatitude(); longitude = location.getLongitude(); } catch (SecurityException exception) { exception.printStackTrace(); } JSONObject reformedObject = new JSONObject(); JSONArray reformedArray = new JSONArray(); try { JSONObject item = new JSONObject(); item.put("timeStamp", date); item.put("connectionID", Constants.CID_BLE); item.put("heartrate", signal); item.put("latitude", latitude); item.put("longitude", longitude); reformedArray.put(item); reformedObject.put("HR", reformedArray); } catch (JSONException e) { e.printStackTrace(); } HttpService httpService = new HttpService(); String responseCode = httpService.executeConn(null, "POST", "http://teamc-iot.calit2.net/IOT/public/rcv_json_data", reformedObject); sendBroadcast(intent); }
From source file:fashiome.android.fragments.MapListFragment.java
@NeedsPermission({ fashiome.android.Manifest.permission.ACCESS_FINE_LOCATION, fashiome.android.Manifest.permission.ACCESS_COARSE_LOCATION }) void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (mMap == null) { // Try to obtain the map from the SupportMapFragment. mMap = mMapFragment.getMap();// w ww. jav a2 s .co m // Check if we were successful in obtaining the map. if (mMap != null) { try { mMap.setMyLocationEnabled(true); } catch (SecurityException e) { e.printStackTrace(); } mMap.getUiSettings().setCompassEnabled(false); mMap.getUiSettings().setZoomControlsEnabled(false); mMap.getUiSettings().setMyLocationButtonEnabled(true); LatLng update = getLastKnownLocation(); if (update != null) { mMap.moveCamera( CameraUpdateFactory.newCameraPosition(CameraPosition.fromLatLngZoom(update, 11.0f))); } mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { Intent i = new Intent(getActivity(), MapFullScreenActivity.class); i.putExtra("items", Parcels.wrap(mItems)); startActivity(i); } }); mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { public boolean onMarkerClick(Marker marker) { // Handle marker click here //send first item for now //listenerForActivity.OnClick(mItems.get(0)); return true; } }); } } }
From source file:de.julielab.jcore.ae.jnet.uima.ConsistencyPreservation.java
/** * this method checks whether the full form (at the position where an * abbreviation was introduced) of an abbreviation is labeled as an entity. * If so, and the abbreviation was not labeled as an entity, the entity * label is copied to the abbreviation. As only the full form where the * abbreviation was introduced is considered, this method should be run * AFTER e.g. doStringBased() which makes sure that all Strings get the same * entity annotation. For modes: _full2acro_ and _acro2full_ * /*from ww w .j a va2 s.co m*/ * @param aJCas * @param entityMentionClassnames * the entity mention class names to be considered * @throws AnalysisEngineProcessException */ public void acroMatch(final JCas aJCas, final TreeSet<String> entityMentionClassnames) throws AnalysisEngineProcessException { // check whether any mode enabled if ((activeModes == null) || (activeModes.size() == 0) || !(activeModes.contains(ConsistencyPreservation.MODE_FULL2ACRO) || activeModes.contains(ConsistencyPreservation.MODE_ACRO2FULL))) return; // TODO needs to be checked for performance // make a set of Annotation objects for entity class names to be // considered // EF, 28.5.2013: Changed from TreeSet to HashSet because our UIMA // annotation types do not implement Comparable which is a prerequisite // for the usage of TreeSet. However, before Java7, there was a bug // allowing the first inserted element not to be Comparable. I hope it // wasn't important in any way that this was a TreeMap. // When using a TreeMap here and running on a Java7 JVM, a // ClassCastException (cannot cast to Comparable) would be risen. Set<EntityMention> entityMentionTypes = null; try { entityMentionTypes = new HashSet<EntityMention>(); for (final String className : entityMentionClassnames) entityMentionTypes .add((EntityMention) JCoReAnnotationTools.getAnnotationByClassName(aJCas, className)); } catch (final SecurityException e1) { e1.printStackTrace(); } catch (final IllegalArgumentException e1) { e1.printStackTrace(); } catch (final ClassNotFoundException e1) { e1.printStackTrace(); } catch (final NoSuchMethodException e1) { e1.printStackTrace(); } catch (final InstantiationException e1) { e1.printStackTrace(); } catch (final IllegalAccessException e1) { e1.printStackTrace(); } catch (final InvocationTargetException e1) { e1.printStackTrace(); } // loop over these full forms final JFSIndexRepository indexes = aJCas.getJFSIndexRepository(); final Iterator<org.apache.uima.jcas.tcas.Annotation> abbrevIter = indexes .getAnnotationIndex(Abbreviation.type).iterator(); while (abbrevIter.hasNext()) { final Abbreviation abbrev = (Abbreviation) abbrevIter.next(); final Annotation fullFormAnnotation = abbrev.getTextReference(); LOGGER.debug("doAbbreviationBased() - checking abbreviation: " + abbrev.getCoveredText()); final ArrayList<EntityMention> mentionList = new ArrayList<EntityMention>(); // check whether abbreviation was identified as an entity mention of // interest for (final EntityMention mention : entityMentionTypes) mentionList.addAll(UIMAUtils.getAnnotations(aJCas, abbrev, mention.getClass())); if ((mentionList == null) || (mentionList.size() == 0)) { // check whether full2acro mode is enabled if (activeModes.contains(ConsistencyPreservation.MODE_FULL2ACRO)) { // if the abbreviation has no entity annotation of the types // of interest LOGGER.debug( "doAbbreviationBased() - no entity mentions of interest found on this abbreviation"); final ArrayList<EntityMention> fullFormMentionList = new ArrayList<EntityMention>(); for (final EntityMention mention : entityMentionTypes) // check whether respective full form does have an // entity annotation of // interest. Important: exact match ! Theses below... fullFormMentionList.addAll( UIMAUtils.getExactAnnotations(aJCas, fullFormAnnotation, mention.getClass())); if ((fullFormMentionList != null) && (fullFormMentionList.size() > 0)) { // if we found an entity mention on the full form (exact // match!), add first entity mention // to abbreviation final EntityMention refEntityMention = fullFormMentionList.get(0); LOGGER.debug("doAbbreviationBased() - but found entity mention on full form"); LOGGER.debug("doAbbreviationBased() - adding annotation to unlabeled entity mention"); try { final EntityMention newEntityMention = (EntityMention) JCoReAnnotationTools .getAnnotationByClassName(aJCas, refEntityMention.getClass().getName()); newEntityMention.setBegin(abbrev.getBegin()); newEntityMention.setEnd(abbrev.getEnd()); newEntityMention.setSpecificType(refEntityMention.getSpecificType()); newEntityMention.setResourceEntryList(refEntityMention.getResourceEntryList()); newEntityMention.setConfidence(refEntityMention.getConfidence()); newEntityMention.setTextualRepresentation(abbrev.getCoveredText()); newEntityMention.setComponentId(COMPONENT_ID + " Abbrev"); newEntityMention.addToIndexes(); } catch (final Exception e) { LOGGER.error( "doAbbreviationBased() - could not get create new entity mention annotation: " + refEntityMention.getClass().getName()); throw new AnalysisEngineProcessException(); } } } } else // check whether acro2full mode is enabled if (activeModes.contains(ConsistencyPreservation.MODE_ACRO2FULL)) if (mentionList.size() > 0) { LOGGER.debug("doAbbreviationBased() - abbreviation has entity mentions of interest"); final ArrayList<EntityMention> fullFormMentionList = new ArrayList<EntityMention>(); for (final EntityMention mention : entityMentionTypes) // check whether respective full form does have an // entity annotation of // interest fullFormMentionList .addAll(UIMAUtils.getAnnotations(aJCas, fullFormAnnotation, mention.getClass())); if ((fullFormMentionList == null) || (fullFormMentionList.size() == 0)) { // if full form has none, add one final EntityMention refEntityMention = mentionList.get(0); LOGGER.debug( "doAbbreviationBased() - but reference full form has no entity mentions of interest"); LOGGER.debug("doAbbreviationBased() - adding annotation to unlabeled entity mention"); try { final EntityMention newEntityMention = (EntityMention) JCoReAnnotationTools .getAnnotationByClassName(aJCas, refEntityMention.getClass().getName()); newEntityMention.setBegin(fullFormAnnotation.getBegin()); newEntityMention.setEnd(fullFormAnnotation.getEnd()); newEntityMention.setSpecificType(refEntityMention.getSpecificType()); newEntityMention.setResourceEntryList(refEntityMention.getResourceEntryList()); newEntityMention.setConfidence(refEntityMention.getConfidence()); newEntityMention.setTextualRepresentation(abbrev.getCoveredText()); newEntityMention.setComponentId(COMPONENT_ID + " Abbrev"); newEntityMention.addToIndexes(); } catch (final Exception e) { LOGGER.error( "doAbbreviationBased() - could not get create new entity mention annotation: " + refEntityMention.getClass().getName()); throw new AnalysisEngineProcessException(); } } } } }
From source file:org.apache.struts.extras.SecureJakartaStreamMultiPartRequest.java
/** * Processes the FileItemStream as a file field. * * @param itemStream//from w w w. j a va2s. c om * @param location */ private void processFileItemStreamAsFileField(FileItemStream itemStream, String location) { File file = null; try { // Create the temporary upload file. file = createTemporaryFile(itemStream.getName(), location); if (streamFileToDisk(itemStream, file)) createFileInfoFromItemStream(itemStream, file); } catch (IOException e) { if (file != null) { try { file.delete(); } catch (SecurityException se) { se.printStackTrace(); LOG.warn("Failed to delete '#0' due to security exception above.", file.getName()); } } } }