List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:org.noorganization.instalist.server.api.RecipeResource.java
/** * Creates the recipe.//from www.j a v a 2s . c om * @param _groupId The id of the group that should contain the new recipe. * @param _entity Data to change. */ @POST @TokenSecured @Consumes("application/json") @Produces({ "application/json" }) public Response postRecipe(@PathParam("groupid") int _groupId, RecipeInfo _entity) throws Exception { try { if (_entity.getUUID() == null || (_entity.getName() != null && _entity.getName().length() == 0) || (_entity.getDeleted() != null && _entity.getDeleted())) return ResponseFactory.generateBadRequest(CommonEntity.INVALID_DATA); UUID toCreate; try { toCreate = UUID.fromString(_entity.getUUID()); } catch (IllegalArgumentException _e) { return ResponseFactory.generateBadRequest(CommonEntity.INVALID_UUID); } Instant created; if (_entity.getLastChanged() != null) { created = _entity.getLastChanged().toInstant(); if (Instant.now().isBefore(created)) return ResponseFactory.generateBadRequest(CommonEntity.INVALID_CHANGEDATE); } else created = Instant.now(); EntityManager manager = DatabaseHelper.getInstance().getManager(); IRecipeController recipeController = ControllerFactory.getRecipeController(manager); try { recipeController.add(_groupId, toCreate, _entity.getName(), created); } catch (ConflictException _e) { return ResponseFactory.generateConflict( new Error().withMessage("The sent data would " + "conflict with saved recipe.")); } finally { manager.close(); } return ResponseFactory.generateCreated(null); } catch (Exception _e) { _e.printStackTrace(); throw _e; } }
From source file:org.cobaltians.cobalt.activities.CobaltActivity.java
public void setupBars(JSONObject configuration) { Toolbar topBar = (Toolbar) findViewById(getTopBarId()); // TODO: use LinearLayout for bottomBar instead to handle groups //LinearLayout bottomBar = (LinearLayout) findViewById(getBottomBarId()); BottomBar bottomBar = (BottomBar) findViewById(getBottomBarId()); // TODO: make bars more flexible if (topBar == null || bottomBar == null) { if (Cobalt.DEBUG) Log.w(Cobalt.TAG, TAG//from ww w . j a va 2s . co m + " - setupBars: activity does not have an action bar and/or does not contain a bottom bar."); return; } setSupportActionBar(topBar); ActionBar actionBar = getSupportActionBar(); // Default if (actionBar != null) { actionBar.setTitle(null); if (sActivitiesArrayList.size() == 1) { actionBar.setDisplayHomeAsUpEnabled(false); } else { actionBar.setDisplayHomeAsUpEnabled(true); } } if (configuration != null) { // Background color // TODO: apply on overflow popup String backgroundColor = configuration.optString(Cobalt.kBarsBackgroundColor, null); if (backgroundColor == null) { backgroundColor = getDefaultActionBarBackgroundColor(); } try { int backgroundColorInt = Cobalt.parseColor(backgroundColor); if (actionBar != null) actionBar.setBackgroundDrawable(new ColorDrawable(backgroundColorInt)); bottomBar.setBackgroundColor(backgroundColorInt); } catch (IllegalArgumentException exception) { if (Cobalt.DEBUG) { Log.w(Cobalt.TAG, TAG + " - setupBars: backgroundColor " + backgroundColor + " format not supported, use (#)RGB or (#)RRGGBB(AA)."); } exception.printStackTrace(); } // Color (default: system) int colorInt = CobaltFontManager.DEFAULT_COLOR; boolean applyColor = false; String color = configuration.optString(Cobalt.kBarsColor, null); if (color == null) color = getDefaultActionBarTextColor(); try { colorInt = Cobalt.parseColor(color); applyColor = true; } catch (IllegalArgumentException exception) { if (Cobalt.DEBUG) { Log.w(Cobalt.TAG, TAG + " - setupBars: color " + color + " format not supported, use (#)RGB or (#)RRGGBB(AA)."); } exception.printStackTrace(); } // Logo String logo = configuration.optString(Cobalt.kBarsIcon, null); if (logo != null) { Drawable logoDrawable = null; int logoResId = getResourceIdentifier(logo); if (logoResId != 0) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { logoDrawable = getResources().getDrawable(logoResId, null); } else { logoDrawable = getResources().getDrawable(logoResId); } if (applyColor && logoDrawable != null) { logoDrawable.setColorFilter(colorInt, PorterDuff.Mode.SRC_ATOP); } } catch (Resources.NotFoundException exception) { Log.w(Cobalt.TAG, TAG + " - setupBars: " + logo + " resource not found."); exception.printStackTrace(); } } else { logoDrawable = CobaltFontManager.getCobaltFontDrawable(this, logo, colorInt); } topBar.setLogo(logoDrawable); if (actionBar != null) actionBar.setDisplayShowHomeEnabled(true); } else { if (actionBar != null) actionBar.setDisplayShowHomeEnabled(false); } // Title String title = configuration.optString(Cobalt.kBarsTitle, null); if (title != null) { if (actionBar != null) actionBar.setTitle(title); } else { if (actionBar != null) actionBar.setDisplayShowTitleEnabled(false); } // Visible JSONObject visible = configuration.optJSONObject(Cobalt.kBarsVisible); if (visible != null) setActionBarVisible(visible); // Up JSONObject navigationIcon = configuration.optJSONObject(Cobalt.kBarsNavigationIcon); if (navigationIcon != null) { boolean enabled = navigationIcon.optBoolean(Cobalt.kNavigationIconEnabled, true); if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(enabled); Drawable navigationIconDrawable = null; String icon = navigationIcon.optString(Cobalt.kNavigationIconIcon, null); if (icon != null) { int iconResId = getResourceIdentifier(icon); if (iconResId != 0) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { navigationIconDrawable = getResources().getDrawable(iconResId, null); } else { navigationIconDrawable = getResources().getDrawable(iconResId); } } catch (Resources.NotFoundException exception) { Log.w(Cobalt.TAG, TAG + " - setupBars: " + logo + " resource not found."); exception.printStackTrace(); } } else { navigationIconDrawable = CobaltFontManager.getCobaltFontDrawable(this, icon, colorInt); } topBar.setNavigationIcon(navigationIconDrawable); } } if (applyColor) { topBar.setTitleTextColor(colorInt); Drawable overflowIconDrawable = topBar.getOverflowIcon(); // should never be null but sometimes.... if (overflowIconDrawable != null) overflowIconDrawable.setColorFilter(colorInt, PorterDuff.Mode.SRC_ATOP); Drawable navigationIconDrawable = topBar.getNavigationIcon(); // should never be null but sometimes.... if (navigationIconDrawable != null) navigationIconDrawable.setColorFilter(colorInt, PorterDuff.Mode.SRC_ATOP); } } }
From source file:jp.aegif.nemaki.cmis.aspect.type.impl.TypeManagerImpl.java
/** * List up specification-default property ids * * @return/* w w w . j a va 2s . c om*/ */ @Override public List<String> getSystemPropertyIds() { List<String> ids = new ArrayList<String>(); Field[] fields = PropertyIds.class.getDeclaredFields(); for (Field field : fields) { try { String cmisId = (String) (field.get(null)); ids.add(cmisId); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return ids; }
From source file:com.arkami.myidkey.activity.KeyCardEditActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if ((resultCode == RESULT_OK)) { ///*from w ww . j av a 2 s . c o m*/ File file = null; FileObject fileObject = new FileObject(); fileObject.setKeyCardAttribute(true); if ((requestCode == CHOOSE_IMAGE_ACTIVITY_REQUEST_CODE) || (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE)) { // File image; try { image = new File(getImageUrlFromResult(data)); // copy file File destination = new File( KeyCardEditActivity.this.getFilesDir() + getString(R.string.key_cards_files_folder)); String copyToFileName = destination.getPath() + "/" + image.getName(); FileChooserActivity.copyFiles(image, destination, KeyCardEditActivity.this); image = new File(copyToFileName); } catch (IllegalArgumentException ex) { Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show(); ex.printStackTrace(); return; } fileObject.setFileType(1L); fileObject.setKeyCardAttribute(true); fileObject.setName(image.getName()); fileObject.setPathToFile(image.getPath()); fileObject.setSize(image.getTotalSpace()); fileObject.setCreateDate(new Date().getTime()); fileObject.setModifyDate(new Date().getTime()); addFileToList(fileObject); return; // File file = null; // FileObject fileObject = new FileObject(); // fileObject.setKeyCardAttribute(true); // if ((requestCode == CHOOSE_IMAGE_ACTIVITY_REQUEST_CODE) // || (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE)) { // fileObject.setFileType(Cache.getInstance(this).getFileTypeId( // FileTypeEnum.photo)); // String selectedImageUrl; // if (data == null) { // selectedImageUrl = photoUri.getPath(); // } else { // String[] filePathColumn = {MediaColumns.DATA}; // Cursor cursor = getContentResolver().query(data.getData(), // filePathColumn, null, null, null); // cursor.moveToFirst(); // int columnIndex = cursor.getColumnIndex(filePathColumn[0]); // selectedImageUrl = cursor.getString(columnIndex); // cursor.close(); // } // if (selectedImageUrl == null) { // return; // } // // // if ((selectedImageUrl != null)) { // file = new File(selectedImageUrl); // if ((file != null) && (file.exists()) && (file.isFile()) // && (file.canRead())) { // // try { // // Common.copyFileToAppFolder(file, this); // // move to receiving message // fileObject.setCreateDate(new Date().getTime()); // fileObject.setModifyDate(new Date().getTime()); // fileObject.setName(file.getName()); // fileObject.setPathToFile( file.getPath()); // //fileObject.setPathToFile("/myAppFolder/" + file.getName()); // fileObject.setSize(file.length()); // fileObject.setId(fileDataSource.insert(fileObject)); // // // // } catch (IOException e) { // // e.printStackTrace(); // // } // // } else{ // Log.w("key card File is null", (file == null) + ""); // Log.w("key card File is existing", file.exists() + ""); // Log.w("key card File is file",file.isFile() + ""); // Log.w("key card File is readable", file.canRead() + ""); // } // } } if ((requestCode == CHOOSE_AUDIO_ACTIVITY_REQUEST_CODE) || (requestCode == CAPTURE_AUDIO_ACTIVITY_REQUEST_CODE)) { fileObject.setFileType(Cache.getInstance(this).getFileTypeId(FileTypeEnum.audio)); Uri selectedAudio = null; if (data != null) { selectedAudio = data.getData(); } String[] filePathColumn = { MediaStore.Audio.Media.DATA }; if ((selectedAudio != null) && (filePathColumn != null)) { Cursor cursor = getContentResolver().query(selectedAudio, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); file = new File(filePath); File destination = new File( KeyCardEditActivity.this.getFilesDir() + getString(R.string.key_cards_files_folder)); String copyToFileName = destination.getPath() + "/" + file.getName(); FileChooserActivity.copyFiles(file, destination, KeyCardEditActivity.this); file = new File(copyToFileName); fileObject.setCreateDate(new Date().getTime()); fileObject.setModifyDate(new Date().getTime()); fileObject.setName(file.getName()); fileObject.setPathToFile(file.getPath()); fileObject.setSize(file.length()); fileObject.setKeyCardAttribute(true); fileObject.setId(fileDataSource.insert(fileObject)); // appAudios.add(file); } } // addFileToList(fileObject); // try { // Common.copyFileToAppFolder(audio, this); // XXX duplicate code long[] newIds = Arrays.copyOf(keyCard.getFileIds(), keyCard.getFileIds().length + 1); long newId = fileObject.getId(); newIds[newIds.length - 1] = newId; Toast.makeText(this, newId + "", Toast.LENGTH_SHORT).show(); keyCard.setFileIds(newIds); // keyCardDataSource.update(keyCard); Log.w("file ", "added"); } Toast.makeText(this, "no file", Toast.LENGTH_LONG).show(); // super.onActivityResult(requestCode, resultCode, data); }
From source file:com.cyberway.issue.crawler.admin.CrawlJobHandler.java
/** * Looks in conf dir for a profiles dir. * @return the directory where profiles are stored else null if none * available/* ww w. j a v a 2 s . c o m*/ * @throws IOException */ private File getProfilesDirectory() throws IOException { URL webappProfilePath = Heritrix.class.getResource("/" + PROFILES_DIR_NAME); if (webappProfilePath != null) { try { return new File(new URI(webappProfilePath.toString())); } catch (java.lang.IllegalArgumentException e) { // e.g. "profiles" within a jar file // try Heritrix.getConfdir() in this case } catch (java.net.URISyntaxException e) { e.printStackTrace(); } } return (Heritrix.getConfdir(false) == null) ? null : new File(Heritrix.getConfdir().getAbsolutePath(), PROFILES_DIR_NAME); }
From source file:com.topsec.tsm.sim.report.util.ReportUiUtil.java
/** * /*from w w w. j a v a 2 s.c o m*/ * ???[] getDeclaredMethods * * @param Object * obj ?? * @return String * */ public static String objReflect(Object obj) { StringBuffer reValue = new StringBuffer(); Method[] method = obj.getClass().getDeclaredMethods(); String methodName = null; String value = null; for (int j = 0; j < method.length; j++) { methodName = method[j].getName(); reValue.append("mname:").append(methodName); if (method[j].getName().indexOf("get") >= 0) { try { value = method[j].invoke(obj) + ""; } catch (IllegalArgumentException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } catch (IllegalAccessException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } catch (InvocationTargetException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } reValue.append(" ").append("mvalue:").append(value).append(" "); } } return reValue.toString(); }
From source file:ca.sqlpower.sqlobject.SQLDatabase.java
/** * Removes all children, closes and discards the JDBC connection. * Unless {@link #playPenDatabase} is true *///from w w w . j a v a2 s. c om protected synchronized void reset() { if (playPenDatabase) { // preserve the objects that are in the Target system when // the connection spec changes logger.debug("Ignoring Reset request for: " + getDataSource()); //$NON-NLS-1$ populated = true; } else { // discard everything and reload (this is generally for source systems) logger.debug("Resetting: " + getDataSource()); //$NON-NLS-1$ // tear down old connection stuff try { begin("Resetting Database " + this); for (int i = getChildrenWithoutPopulating().size() - 1; i >= 0; i--) { removeChild(getChildrenWithoutPopulating().get(i)); } populated = false; commit(); } catch (IllegalArgumentException e) { rollback(e.getMessage()); throw new RuntimeException(e); } catch (ObjectDependentException e) { rollback(e.getMessage()); throw new RuntimeException(e); } } // destroy connection pool in either case (it still points to the old data source) if (connectionPool != null) { try { connectionPool.close(); } catch (Exception e) { e.printStackTrace(); } } connectionPool = null; }
From source file:de.geeksfactory.opacclient.apis.SISIS.java
protected void parse_medialist(List<LentItem> media, Document doc, int offset) { Elements copytrs = doc.select(".data tr"); doc.setBaseUri(opac_url);// w w w.ja va2s . c om DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN); int trs = copytrs.size(); if (trs == 1) { return; } assert (trs > 0); for (int i = 1; i < trs; i++) { Element tr = copytrs.get(i); LentItem item = new LentItem(); if (tr.text().contains("keine Daten")) { return; } item.setTitle(tr.child(1).select("strong").text().trim()); try { item.setAuthor(tr.child(1).html().split("<br[ /]*>")[1].trim()); String[] col2split = tr.child(2).html().split("<br[ /]*>"); String deadline = col2split[0].trim(); if (deadline.contains("-")) { deadline = deadline.split("-")[1].trim(); } try { item.setDeadline(fmt.parseLocalDate(deadline).toString()); } catch (IllegalArgumentException e1) { e1.printStackTrace(); } if (col2split.length > 1) { item.setHomeBranch(col2split[1].trim()); } if (tr.select("a").size() > 0) { for (Element link : tr.select("a")) { String href = link.attr("abs:href"); Map<String, String> hrefq = getQueryParamsFirst(href); if (hrefq.get("methodToCall").equals("renewalPossible")) { item.setProlongData(offset + "$" + href.split("\\?")[1]); item.setRenewable(true); break; } } } else if (tr.select(".textrot, .textgruen, .textdunkelblau").size() > 0) { item.setProlongData("" + tr.select(".textrot, .textgruen, .textdunkelblau").text()); item.setRenewable(false); } } catch (Exception ex) { ex.printStackTrace(); } media.add(item); } assert (media.size() == trs - 1); }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public void cancelTeslaUnread() { new Thread(new Runnable() { @Override/*from w w w .j a va2 s .c om*/ public void run() { try { ContentValues cv = new ContentValues(); cv.put("tag", "com.daiv.android.twitter/com.daiv.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(); }