List of usage examples for java.lang IllegalArgumentException toString
public String toString()
From source file:org.apache.openjpa.jdbc.sql.MySQLDictionary.java
@Override public void connectedConfiguration(Connection conn) throws SQLException { super.connectedConfiguration(conn); DatabaseMetaData metaData = conn.getMetaData(); int maj = 0;/* w w w .j av a2 s . c o m*/ int min = 0; if (isJDBC3) { maj = metaData.getDatabaseMajorVersion(); min = metaData.getDatabaseMinorVersion(); } else { try { // The product version looks like 4.1.3-nt or 5.1.30 String productVersion = metaData.getDatabaseProductVersion(); int[] versions = getMajorMinorVersions(productVersion); maj = versions[0]; min = versions[1]; } catch (IllegalArgumentException e) { // we don't understand the version format. // That is ok. We just take the default values. if (log.isWarnEnabled()) log.warn(e.toString(), e); } } if (maj < 4 || (maj == 4 && min < 1)) { supportsSubselect = false; allowsAliasInBulkClause = false; supportsForeignKeysComposite = false; } if (maj > 5 || (maj == 5 && min >= 1)) supportsXMLColumn = true; if (metaData.getDriverMajorVersion() < 5) driverDeserializesBlobs = true; }
From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
private void initMediaPlayer() { String PATH_TO_FILE = voice6; mediaPlayer = new MediaPlayer(); try {/*from w w w . j a va 2 s.c om*/ mediaPlayer.setDataSource(PATH_TO_FILE); mediaPlayer.prepare(); if (isInDebugMode) Toast.makeText(this, PATH_TO_FILE, Toast.LENGTH_LONG).show(); stateMediaPlayer = stateMP_NotStarter; } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show(); stateMediaPlayer = stateMP_Error; } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show(); stateMediaPlayer = stateMP_Error; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show(); stateMediaPlayer = stateMP_Error; } }
From source file:org.apache.hadoop.yarn.server.nodemanager.TestLinuxContainerExecutor.java
@Test public void testNonsecureUsernamePattern() throws Exception { Assume.assumeTrue(shouldRun());/*from w ww . j a v a2s. c om*/ try { // nonsecure default Configuration conf = new YarnConfiguration(); conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "simple"); UserGroupInformation.setConfiguration(conf); LinuxContainerExecutor lce = new LinuxContainerExecutor(); lce.setConf(conf); lce.verifyUsernamePattern("foo"); try { lce.verifyUsernamePattern("foo/x"); fail(); } catch (IllegalArgumentException ex) { // NOP } catch (Throwable ex) { fail(ex.toString()); } // nonsecure custom setting conf.set(YarnConfiguration.NM_NONSECURE_MODE_USER_PATTERN_KEY, "foo"); lce = new LinuxContainerExecutor(); lce.setConf(conf); lce.verifyUsernamePattern("foo"); try { lce.verifyUsernamePattern("bar"); fail(); } catch (IllegalArgumentException ex) { // NOP } catch (Throwable ex) { fail(ex.toString()); } // secure, pattern matching does not kick in. conf = new YarnConfiguration(); conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos"); UserGroupInformation.setConfiguration(conf); lce = new LinuxContainerExecutor(); lce.setConf(conf); lce.verifyUsernamePattern("foo"); lce.verifyUsernamePattern("foo/w"); } finally { Configuration conf = new YarnConfiguration(); conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "simple"); UserGroupInformation.setConfiguration(conf); } }
From source file:nl.b3p.viewer.stripes.SplitFeatureActionBean.java
public Resolution split() throws JSONException { JSONObject json = new JSONObject(); json.put("success", Boolean.FALSE); String error = null;/*from ww w . j a va 2 s. c om*/ if (appLayer == null) { error = "Invalid parameters"; } else if (unauthorized) { error = "Not authorized"; } else { FeatureSource fs = null; try { if (this.splitFeatureFID == null) { throw new IllegalArgumentException(getBundle().getString("viewer.splitfeatureactionbean.1")); } if (this.toSplitWithFeature == null) { throw new IllegalArgumentException(getBundle().getString("viewer.splitfeatureactionbean.2")); } fs = this.layer.getFeatureType().openGeoToolsFeatureSource(); if (!(fs instanceof SimpleFeatureStore)) { throw new IllegalArgumentException(getBundle().getString("viewer.splitfeatureactionbean.3")); } this.store = (SimpleFeatureStore) fs; List<FeatureId> ids = this.splitFeature(); if (ids.size() < 2) { throw new IllegalArgumentException(getBundle().getString("viewer.splitfeatureactionbean.4")); } json.put("fids", ids); json.put("success", Boolean.TRUE); } catch (IllegalArgumentException e) { log.warn("Split error", e); error = e.getLocalizedMessage(); } catch (Exception e) { log.error(String.format("Exception splitting feature %s", this.splitFeatureFID), e); error = e.toString(); if (e.getCause() != null) { error += "; cause: " + e.getCause().toString(); } } finally { if (fs != null) { fs.getDataStore().dispose(); } } } if (error != null) { json.put("error", error); } return new StreamingResolution("application/json", new StringReader(json.toString())); }
From source file:org.wso2.iot.agent.services.operation.OperationManagerWorkProfile.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void enableSystemApp(String packageName) { try {//www . j av a 2 s .c o m getDevicePolicyManager().enableSystemApp(getCdmDeviceAdmin(), packageName); } catch (IllegalArgumentException e) { Log.e(TAG, "App is not available on the device to enable. " + e.toString()); } }
From source file:com.ushahidi.android.app.ui.phone.ListMapActivity.java
@Override protected void onLoaded(boolean success) { try {/* ww w . jav a2 s . c o m*/ if (success) { if (Preferences.isCheckinEnabled == 1) { toastLong(R.string.checkin_is_enabled); goToCheckins(); } else { goToReports(); } } else { toastLong(R.string.failed); } } catch (IllegalArgumentException e) { log(e.toString()); } }
From source file:nl.b3p.viewer.stripes.MergeFeaturesActionBean.java
public Resolution merge() throws JSONException { JSONObject json = new JSONObject(); json.put("success", Boolean.FALSE); String error = null;/*from ww w .j ava2 s.co m*/ if (appLayer == null) { error = getBundle().getString("viewer.mergefeaturesactionbean.1"); } else if (unauthorized) { error = getBundle().getString("viewer.mergefeaturesactionbean.2"); } else { FeatureSource fs = null; try { if (this.fidA == null || this.fidB == null) { throw new IllegalArgumentException(getBundle().getString("viewer.mergefeaturesactionbean.3")); } if (this.strategy == null) { throw new IllegalArgumentException(getBundle().getString("viewer.mergefeaturesactionbean.4")); } fs = this.layer.getFeatureType().openGeoToolsFeatureSource(); if (!(fs instanceof SimpleFeatureStore)) { throw new IllegalArgumentException(getBundle().getString("viewer.mergefeaturesactionbean.5")); } this.store = (SimpleFeatureStore) fs; List<FeatureId> ids = this.mergeFeatures(); if (ids.isEmpty()) { throw new IllegalArgumentException(getBundle().getString("viewer.mergefeaturesactionbean.6")); } if (ids.size() > 1) { throw new IllegalArgumentException(getBundle().getString("viewer.mergefeaturesactionbean.7")); } json.put("fids", ids); json.put("success", Boolean.TRUE); } catch (IllegalArgumentException e) { LOG.warn("Merge error", e); error = e.getLocalizedMessage(); } catch (Exception e) { LOG.error(MessageFormat.format(getBundle().getString("viewer.mergefeaturesactionbean.8"), this.fidB, this.fidA, e)); error = e.toString(); if (e.getCause() != null) { error += "; cause: " + e.getCause().toString(); } } finally { if (fs != null) { fs.getDataStore().dispose(); } } } if (error != null) { json.put("error", error); } return new StreamingResolution("application/json", new StringReader(json.toString())); }
From source file:com.radicaldynamic.groupinform.activities.LauncherActivity.java
@Override protected void onDestroy() { super.onDestroy(); final String tt = t + "onDestroy(): "; // Unbind from our services if (Collect.getInstance().getCouchService() instanceof ServiceConnection) { try {// www . j a v a2 s.c o m if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "unbinding from CouchService"); unbindService(Collect.getInstance().getCouchService()); } catch (IllegalArgumentException e) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, tt + "CouchService not registered: " + e.toString()); } } if (Collect.getInstance().getDbService() instanceof DatabaseService) { try { if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "unbinding from DatabaseService"); unbindService(mDatabaseConnection); } catch (IllegalArgumentException e) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, tt + "DatabaseService not registered: " + e.toString()); } } if (Collect.getInstance().getIoService() instanceof InformOnlineService) { try { if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, tt + "unbinding from InformOnlineService"); unbindService(mOnlineConnection); } catch (IllegalArgumentException e) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, tt + "InformOnlineService not registered: " + e.toString()); } } // User has reset GC Mobile (see http://stackoverflow.com/questions/2042222/close-application) if (mExitApplication) { exitApplication(); } }
From source file:edu.ku.brc.af.ui.forms.persist.ViewLoader.java
/** * Processes all the rows/*w w w . j a va2 s . c o m*/ * @param element the parent DOM element of the rows * @param cellRows the list the rows are to be added to */ protected static void processRows(final Element element, final List<FormRowIFace> cellRows, final DBTableInfo tableinfo) { Element rowsElement = (Element) element.selectSingleNode("rows"); if (rowsElement != null) { byte rowNumber = 0; for (Iterator<?> i = rowsElement.elementIterator("row"); i.hasNext();) { Element rowElement = (Element) i.next(); FormRow formRow = new FormRow(); formRow.setRowNumber(rowNumber); for (Iterator<?> cellIter = rowElement.elementIterator("cell"); cellIter.hasNext();) { Element cellElement = (Element) cellIter.next(); String cellId = getAttr(cellElement, ID, ""); String cellName = getAttr(cellElement, NAME, cellId); // let the name default to the id if it doesn't have a name int colspan = getAttr(cellElement, "colspan", 1); int rowspan = getAttr(cellElement, "rowspan", 1); /*boolean isReq = getAttr(cellElement, ISREQUIRED, false); if (isReq) { System.err.println(String.format("%s\t%s\t%s\t%s", gViewDef.getName(), cellId, cellName, tableinfo != null ? tableinfo.getTitle() : "N/A")); }*/ FormCell.CellType cellType = null; FormCellIFace cell = null; try { cellType = FormCellIFace.CellType.valueOf(cellElement.attributeValue(TYPE)); } catch (java.lang.IllegalArgumentException ex) { FormDevHelper.appendFormDevError(ex.toString()); FormDevHelper.appendFormDevError(String.format("Cell Name[%s] Id[%s] Type[%s]", cellName, cellId, cellElement.attributeValue(TYPE))); return; } if (doFieldVerification && fldVerTableInfo != null && cellType == FormCellIFace.CellType.field && StringUtils.isNotEmpty(cellId) && !cellName.equals("this")) { processFieldVerify(cellName, cellId, rowNumber); } switch (cellType) { case label: { cell = formRow.addCell(new FormCellLabel(cellId, cellName, getLabel(cellElement), getAttr(cellElement, "labelfor", ""), getAttr(cellElement, "icon", null), getAttr(cellElement, "recordobj", false), colspan)); String initialize = getAttr(cellElement, INITIALIZE, null); if (StringUtils.isNotEmpty(initialize)) { cell.setProperties(UIHelper.parseProperties(initialize)); } break; } case separator: { cell = formRow.addCell(new FormCellSeparator(cellId, cellName, getLabel(cellElement), getAttr(cellElement, "collapse", ""), colspan)); String initialize = getAttr(cellElement, INITIALIZE, null); if (StringUtils.isNotEmpty(initialize)) { cell.setProperties(UIHelper.parseProperties(initialize)); } break; } case field: { String uitypeStr = getAttr(cellElement, "uitype", ""); String format = getAttr(cellElement, "format", ""); String formatName = getAttr(cellElement, "formatname", ""); String uiFieldFormatterName = getAttr(cellElement, "uifieldformatter", ""); int cols = getAttr(cellElement, "cols", DEFAULT_COLS); // XXX PREF for default width of text field int rows = getAttr(cellElement, "rows", DEFAULT_ROWS); // XXX PREF for default heightof text area String validationType = getAttr(cellElement, "valtype", "Changed"); String validationRule = getAttr(cellElement, VALIDATION, ""); String initialize = getAttr(cellElement, INITIALIZE, ""); boolean isRequired = getAttr(cellElement, ISREQUIRED, false); String pickListName = getAttr(cellElement, "picklist", ""); if (isNotEmpty(format) && isNotEmpty(formatName)) { String msg = "Both format and formatname cannot both be set! [" + cellName + "] ignoring format"; log.error(msg); FormDevHelper.appendFormDevError(msg); format = ""; } Properties properties = UIHelper.parseProperties(initialize); if (isEmpty(uitypeStr)) { // XXX DEBUG ONLY PLease REMOVE LATER //log.debug("***************************************************************************"); //log.debug("***** Cell Id["+cellId+"] Name["+cellName+"] uitype is empty and should be 'text'. (Please Fix!)"); //log.debug("***************************************************************************"); uitypeStr = "text"; } // THis switch is used to get the "display type" and // set up other vars needed for creating the controls FormCellFieldIFace.FieldType uitype = null; try { uitype = FormCellFieldIFace.FieldType.valueOf(uitypeStr); } catch (java.lang.IllegalArgumentException ex) { FormDevHelper.appendFormDevError(ex.toString()); FormDevHelper.appendFormDevError(String.format( "Cell Name[%s] Id[%s] uitype[%s] is in error", cellName, cellId, uitypeStr)); uitype = FormCellFieldIFace.FieldType.text; // default to text } String dspUITypeStr = null; switch (uitype) { case textarea: dspUITypeStr = getAttr(cellElement, DSPUITYPE, "dsptextarea"); break; case textareabrief: dspUITypeStr = getAttr(cellElement, DSPUITYPE, "textareabrief"); break; case querycbx: { dspUITypeStr = getAttr(cellElement, DSPUITYPE, "textfieldinfo"); String fmtName = TypeSearchForQueryFactory.getInstance() .getDataObjFormatterName(properties.getProperty("name")); if (isEmpty(formatName) && isNotEmpty(fmtName)) { formatName = fmtName; } break; } case formattedtext: { validationRule = getAttr(cellElement, VALIDATION, "formatted"); // XXX Is this OK? dspUITypeStr = getAttr(cellElement, DSPUITYPE, "formattedtext"); //------------------------------------------------------- // This part should be moved to the ViewFactory // because it is the only part that need the Schema Information //------------------------------------------------------- if (isNotEmpty(uiFieldFormatterName)) { UIFieldFormatterIFace uiFormatter = UIFieldFormatterMgr.getInstance() .getFormatter(uiFieldFormatterName); if (uiFormatter == null) { String msg = "Couldn't find formatter[" + uiFieldFormatterName + "]"; log.error(msg); FormDevHelper.appendFormDevError(msg); uiFieldFormatterName = ""; uitype = FormCellFieldIFace.FieldType.text; } } else // ok now check the schema for the UI formatter { if (tableinfo != null) { DBFieldInfo fieldInfo = tableinfo.getFieldByName(cellName); if (fieldInfo != null) { if (fieldInfo.getFormatter() != null) { uiFieldFormatterName = fieldInfo.getFormatter().getName(); } else if (fieldInfo.getDataClass().isAssignableFrom(Date.class) || fieldInfo.getDataClass().isAssignableFrom(Calendar.class)) { String msg = "Missing Date Formatter for [" + cellName + "]"; log.error(msg); FormDevHelper.appendFormDevError(msg); uiFieldFormatterName = "Date"; UIFieldFormatterIFace uiFormatter = UIFieldFormatterMgr.getInstance() .getFormatter(uiFieldFormatterName); if (uiFormatter == null) { uiFieldFormatterName = ""; uitype = FormCellFieldIFace.FieldType.text; } } else { uiFieldFormatterName = ""; uitype = FormCellFieldIFace.FieldType.text; } } } } break; } case url: dspUITypeStr = getAttr(cellElement, DSPUITYPE, uitypeStr); properties = UIHelper.parseProperties(initialize); break; case list: case image: case tristate: case checkbox: case password: dspUITypeStr = getAttr(cellElement, DSPUITYPE, uitypeStr); break; case plugin: case button: dspUITypeStr = getAttr(cellElement, DSPUITYPE, uitypeStr); properties = UIHelper.parseProperties(initialize); String ttl = properties.getProperty(TITLE); if (ttl != null) { properties.put(TITLE, getResourceLabel(ttl)); } break; case spinner: dspUITypeStr = getAttr(cellElement, DSPUITYPE, "dsptextfield"); properties = UIHelper.parseProperties(initialize); break; case combobox: dspUITypeStr = getAttr(cellElement, DSPUITYPE, "textpl"); if (tableinfo != null) { DBFieldInfo fieldInfo = tableinfo.getFieldByName(cellName); if (fieldInfo != null) { if (StringUtils.isNotEmpty(pickListName)) { fieldInfo.setPickListName(pickListName); } else { pickListName = fieldInfo.getPickListName(); } } } break; default: dspUITypeStr = getAttr(cellElement, DSPUITYPE, "dsptextfield"); break; } //switch FormCellFieldIFace.FieldType dspUIType = FormCellFieldIFace.FieldType.valueOf(dspUITypeStr); try { dspUIType = FormCellFieldIFace.FieldType.valueOf(dspUITypeStr); } catch (java.lang.IllegalArgumentException ex) { FormDevHelper.appendFormDevError(ex.toString()); FormDevHelper.appendFormDevError(String.format( "Cell Name[%s] Id[%s] dspuitype[%s] is in error", cellName, cellId, dspUIType)); uitype = FormCellFieldIFace.FieldType.label; // default to text } // check to see see if the validation is a node in the cell if (isEmpty(validationRule)) { Element valNode = (Element) cellElement.selectSingleNode(VALIDATION); if (valNode != null) { String str = valNode.getTextTrim(); if (isNotEmpty(str)) { validationRule = str; } } } boolean isEncrypted = getAttr(cellElement, "isencrypted", false); boolean isReadOnly = uitype == FormCellFieldIFace.FieldType.dsptextfield || uitype == FormCellFieldIFace.FieldType.dsptextarea || uitype == FormCellFieldIFace.FieldType.label; FormCellField field = new FormCellField(FormCellIFace.CellType.field, cellId, cellName, uitype, dspUIType, format, formatName, uiFieldFormatterName, isRequired, cols, rows, colspan, rowspan, validationType, validationRule, isEncrypted); String labelStr = uitype == FormCellFieldIFace.FieldType.checkbox ? getLabel(cellElement) : getAttr(cellElement, "label", ""); field.setLabel(labelStr); field.setReadOnly(getAttr(cellElement, "readonly", isReadOnly)); field.setDefaultValue(getAttr(cellElement, "default", "")); field.setPickListName(pickListName); field.setChangeListenerOnly(getAttr(cellElement, "changesonly", true) && !isRequired); field.setProperties(properties); cell = formRow.addCell(field); break; } case command: { cell = formRow.addCell(new FormCellCommand(cellId, cellName, getLabel(cellElement), getAttr(cellElement, "commandtype", ""), getAttr(cellElement, "action", ""))); String initialize = getAttr(cellElement, INITIALIZE, null); if (StringUtils.isNotEmpty(initialize)) { cell.setProperties(UIHelper.parseProperties(initialize)); } break; } case panel: { FormCellPanel cellPanel = new FormCellPanel(cellId, cellName, getAttr(cellElement, "paneltype", ""), getAttr(cellElement, "coldef", "p"), getAttr(cellElement, "rowdef", "p"), colspan, rowspan); String initialize = getAttr(cellElement, INITIALIZE, null); if (StringUtils.isNotEmpty(initialize)) { cellPanel.setProperties(UIHelper.parseProperties(initialize)); } processRows(cellElement, cellPanel.getRows(), tableinfo); fixLabels(cellPanel.getName(), cellPanel.getRows(), tableinfo); cell = formRow.addCell(cellPanel); break; } case subview: { Properties properties = UIHelper.parseProperties(getAttr(cellElement, INITIALIZE, null)); String svViewSetName = cellElement.attributeValue("viewsetname"); if (isEmpty(svViewSetName)) { svViewSetName = null; } if (instance.doingResourceLabels && properties != null) { String title = properties.getProperty(TITLE); if (title != null) { properties.setProperty(TITLE, UIRegistry.getResourceString(title)); } } String viewName = getAttr(cellElement, "viewname", null); cell = formRow.addCell(new FormCellSubView(cellId, cellName, svViewSetName, viewName, cellElement.attributeValue("class"), getAttr(cellElement, "desc", ""), getAttr(cellElement, "defaulttype", null), getAttr(cellElement, "rows", DEFAULT_SUBVIEW_ROWS), colspan, rowspan, getAttr(cellElement, "single", false))); cell.setProperties(properties); break; } case iconview: { String vsName = cellElement.attributeValue("viewsetname"); if (isEmpty(vsName)) { vsName = instance.viewSetName; } String viewName = getAttr(cellElement, "viewname", null); cell = formRow.addCell(new FormCellSubView(cellId, cellName, vsName, viewName, cellElement.attributeValue("class"), getAttr(cellElement, "desc", ""), colspan, rowspan)); break; } case statusbar: { cell = formRow.addCell( new FormCell(FormCellIFace.CellType.statusbar, cellId, cellName, colspan, rowspan)); break; } default: { // what is this? log.error("Encountered unknown cell type"); continue; } } // switch cell.setIgnoreSetGet(getAttr(cellElement, "ignore", false)); } cellRows.add(formRow); rowNumber++; } } }