List of usage examples for java.lang IllegalAccessException printStackTrace
public void printStackTrace()
From source file:org.kuali.rice.kew.impl.document.search.DocumentSearchCriteriaBoLookupableHelperService.java
/** * Loads a saved search//from w w w . java 2s . c o m * @return returns true on success to run the loaded search, false on error. */ protected boolean loadSavedSearch(boolean ignoreErrors) { Map<String, String[]> fieldValues = new HashMap<String, String[]>(); String savedSearchName = getSavedSearchName(); if (StringUtils.isEmpty(savedSearchName) || "*ignore*".equals(savedSearchName)) { if (!ignoreErrors) { GlobalVariables.getMessageMap().putError(SAVED_SEARCH_NAME_PARAM, RiceKeyConstants.ERROR_CUSTOM, "You must select a saved search"); } else { //if we're ignoring errors and we got an error just return, no reason to continue. Also set false to indicate not to perform lookup return false; } getFormFields().setFieldValue(SAVED_SEARCH_NAME_PARAM, ""); } if (!GlobalVariables.getMessageMap().hasNoErrors()) { throw new ValidationException("errors in search criteria"); } DocumentSearchCriteria criteria = KEWServiceLocator.getDocumentSearchService() .getSavedSearchCriteria(GlobalVariables.getUserSession().getPrincipalId(), savedSearchName); // get the document type String docTypeName = criteria.getDocumentTypeName(); // update the parameters to include whether or not this is an advanced search if (this.getParameters().containsKey(KRADConstants.ADVANCED_SEARCH_FIELD)) { Map<String, String[]> parameters = this.getParameters(); String[] params = (String[]) parameters.get(KRADConstants.ADVANCED_SEARCH_FIELD); if (ArrayUtils.isNotEmpty(params)) { params[0] = criteria.getIsAdvancedSearch(); this.setParameters(parameters); } } // and set the rows based on doc type setRows(docTypeName); // clear the name of the search in the form //fieldValues.put(SAVED_SEARCH_NAME_PARAM, new String[0]); // set the custom document attribute values on the search form for (Map.Entry<String, List<String>> entry : criteria.getDocumentAttributeValues().entrySet()) { fieldValues.put(entry.getKey(), entry.getValue().toArray(new String[entry.getValue().size()])); } // sets the field values on the form, trying criteria object properties if a field value is not present in the map for (Field field : getFormFields().getFields()) { if (field.getPropertyName() != null && !field.getPropertyName().equals("")) { // UI Fields know whether they are single or multiple value // just set both so they can make the determination and render appropriately String[] values = null; if (fieldValues.get(field.getPropertyName()) != null) { values = fieldValues.get(field.getPropertyName()); } else { //may be on the root of the criteria object, try looking there: try { if (field.isRanged() && field.isDatePicker()) { if (field.getPropertyName() .startsWith(KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX)) { String lowerBoundName = field.getPropertyName().replace( KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX, "") + "From"; Object lowerBoundDate = PropertyUtils.getProperty(criteria, lowerBoundName); if (lowerBoundDate != null) { values = new String[] { CoreApiServiceLocator.getDateTimeService() .toDateTimeString(((org.joda.time.DateTime) lowerBoundDate).toDate()) }; } } else { // the upper bound prefix may or may not be on the propertyName. Using "replace" just in case. String upperBoundName = field.getPropertyName() .replace(KRADConstants.LOOKUP_RANGE_UPPER_BOUND_PROPERTY_PREFIX, "") + "To"; Object upperBoundDate = PropertyUtils.getProperty(criteria, upperBoundName); if (upperBoundDate != null) { values = new String[] { CoreApiServiceLocator.getDateTimeService() .toDateTimeString(((org.joda.time.DateTime) upperBoundDate).toDate()) }; } } } else { values = new String[] { ObjectUtils .toString(PropertyUtils.getProperty(criteria, field.getPropertyName())) }; } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { // e.printStackTrace(); //hmm what to do here, we should be able to find everything either in the search atts or at the base as far as I know. } } if (values != null) { getFormFields().setFieldValue(field, values); } } } return true; }
From source file:org.apache.tomee.embedded.TomEEEmbeddedApplicationRunner.java
public synchronized void start(final Class<?> marker, final Properties config, final String... args) throws Exception { if (started) { return;/* w w w . java 2 s . c o m*/ } ensureAppInit(marker); started = true; final Class<?> appClass = app.getClass(); final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ancestors(appClass))); // setup the container config reading class annotation, using a randome http port and deploying the classpath final Configuration configuration = new Configuration(); final ContainerProperties props = appClass.getAnnotation(ContainerProperties.class); if (props != null) { final Properties runnerProperties = new Properties(); for (final ContainerProperties.Property p : props.value()) { final String name = p.name(); if (name.startsWith("tomee.embedded.application.runner.")) { // allow to tune the Configuration // no need to filter there since it is done in loadFromProperties() runnerProperties.setProperty(name.substring("tomee.embedded.application.runner.".length()), p.value()); } else { configuration.property(name, StrSubstitutor.replaceSystemProperties(p.value())); } } if (!runnerProperties.isEmpty()) { configuration.loadFromProperties(runnerProperties); } } configuration.loadFromProperties(System.getProperties()); // overrides, note that some config are additive by design final List<Method> annotatedMethods = finder .findAnnotatedMethods(org.apache.openejb.testing.Configuration.class); if (annotatedMethods.size() > 1) { throw new IllegalArgumentException("Only one @Configuration is supported: " + annotatedMethods); } for (final Method m : annotatedMethods) { final Object o = m.invoke(app); if (Properties.class.isInstance(o)) { final Properties properties = Properties.class.cast(o); if (configuration.getProperties() == null) { configuration.setProperties(new Properties()); } configuration.getProperties().putAll(properties); } else { throw new IllegalArgumentException("Unsupported " + o + " for @Configuration"); } } final Collection<org.apache.tomee.embedded.LifecycleTask> lifecycleTasks = new ArrayList<>(); final Collection<Closeable> postTasks = new ArrayList<>(); final LifecycleTasks tasks = appClass.getAnnotation(LifecycleTasks.class); if (tasks != null) { for (final Class<? extends org.apache.tomee.embedded.LifecycleTask> type : tasks.value()) { final org.apache.tomee.embedded.LifecycleTask lifecycleTask = type.newInstance(); lifecycleTasks.add(lifecycleTask); postTasks.add(lifecycleTask.beforeContainerStartup()); } } final Map<String, Field> ports = new HashMap<>(); { Class<?> type = appClass; while (type != null && type != Object.class) { for (final Field f : type.getDeclaredFields()) { final RandomPort annotation = f.getAnnotation(RandomPort.class); final String value = annotation == null ? null : annotation.value(); if (value != null && value.startsWith("http")) { f.setAccessible(true); ports.put(value, f); } } type = type.getSuperclass(); } } if (ports.containsKey("http")) { configuration.randomHttpPort(); } // at least after LifecycleTasks to inherit from potential states (system properties to get a port etc...) final Configurers configurers = appClass.getAnnotation(Configurers.class); if (configurers != null) { for (final Class<? extends Configurer> type : configurers.value()) { type.newInstance().configure(configuration); } } final Classes classes = appClass.getAnnotation(Classes.class); String context = classes != null ? classes.context() : ""; context = !context.isEmpty() && context.startsWith("/") ? context.substring(1) : context; Archive archive = null; if (classes != null && classes.value().length > 0) { archive = new ClassesArchive(classes.value()); } final Jars jars = appClass.getAnnotation(Jars.class); final List<URL> urls; if (jars != null) { final Collection<File> files = ApplicationComposers.findFiles(jars); urls = new ArrayList<>(files.size()); for (final File f : files) { urls.add(f.toURI().toURL()); } } else { urls = null; } final WebResource resources = appClass.getAnnotation(WebResource.class); if (resources != null && resources.value().length > 1) { throw new IllegalArgumentException("Only one docBase is supported for now using @WebResource"); } String webResource = null; if (resources != null && resources.value().length > 0) { webResource = resources.value()[0]; } else { final File webapp = new File("src/main/webapp"); if (webapp.isDirectory()) { webResource = "src/main/webapp"; } } if (config != null) { // override other config from annotations configuration.loadFromProperties(config); } final Container container = new Container(configuration); SystemInstance.get().setComponent(TomEEEmbeddedArgs.class, new TomEEEmbeddedArgs(args, null)); SystemInstance.get().setComponent(LifecycleTaskAccessor.class, new LifecycleTaskAccessor(lifecycleTasks)); container.deploy(new Container.DeploymentRequest(context, // call ClasspathSearcher that lazily since container needs to be started to not preload logging urls == null ? new DeploymentsResolver.ClasspathSearcher() .loadUrls(Thread.currentThread().getContextClassLoader()).getUrls() : urls, webResource != null ? new File(webResource) : null, true, null, archive)); for (final Map.Entry<String, Field> f : ports.entrySet()) { switch (f.getKey()) { case "http": setPortField(f.getKey(), f.getValue(), configuration, context, app); break; case "https": break; default: throw new IllegalArgumentException("port " + f.getKey() + " not yet supported"); } } SystemInstance.get().addObserver(app); composerInject(app); final AnnotationFinder appFinder = new AnnotationFinder(new ClassesArchive(appClass)); for (final Method mtd : appFinder.findAnnotatedMethods(PostConstruct.class)) { if (mtd.getParameterTypes().length == 0) { if (!mtd.isAccessible()) { mtd.setAccessible(true); } mtd.invoke(app); } } hook = new Thread() { @Override public void run() { // ensure to log errors but not fail there for (final Method mtd : appFinder.findAnnotatedMethods(PreDestroy.class)) { if (mtd.getParameterTypes().length == 0) { if (!mtd.isAccessible()) { mtd.setAccessible(true); } try { mtd.invoke(app); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getCause()); } } } try { container.close(); } catch (final Exception e) { e.printStackTrace(); } for (final Closeable c : postTasks) { try { c.close(); } catch (final IOException e) { e.printStackTrace(); } } postTasks.clear(); app = null; try { SHUTDOWN_TASKS.remove(this); } catch (final Exception e) { // no-op: that's ok at that moment if not called manually } } }; SHUTDOWN_TASKS.put(hook, hook); }
From source file:au.org.theark.report.web.component.dataextraction.filter.form.QueryFilterForm.java
/** * @return the listEditor of Biospecimens to aliquot *///from w ww.j a v a2 s . co m public AbstractListEditor<QueryFilterVO> buildListEditor() { listEditor = new AbstractListEditor<QueryFilterVO>("queryFilterVOs", new PropertyModel(getModelObject(), "queryFilterVOs")) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void onPopulateItem(final ListItem<QueryFilterVO> item) { item.setOutputMarkupId(true); item.add(new Label("row", "" + (item.getIndex() + 1))); if (copyQueryFilter) { item.getModelObject().setFieldCategory(queryFilterVoToCopy.getFieldCategory()); item.getModelObject().setQueryFilter(queryFilterVoToCopy.getQueryFilter()); item.getModelObject().getQueryFilter() .setValue(queryFilterVoToCopy.getQueryFilter().getValue()); item.getModelObject().getQueryFilter() .setSecondValue(queryFilterVoToCopy.getQueryFilter().getSecondValue()); } initFieldCategoryDdc(item); initFieldDdc(item); initOperatorDdc(item, false, null); // Copy button allows entire row details to be copied item.add(new AjaxEditorButton(Constants.COPY) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { QueryFilterVO queryFilterVO = new QueryFilterVO(); try { PropertyUtils.copyProperties(queryFilterVO, getItem().getModelObject()); PropertyUtils.copyProperties(queryFilterVoToCopy, getItem().getModelObject()); queryFilterVoToCopy.getQueryFilter().setId(null); queryFilterVO.getQueryFilter().setId(null); copyQueryFilter = true; listEditor.addItem(queryFilterVO); target.add(form); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } }.setDefaultFormProcessing(false)); item.add(new AjaxEditorButton(Constants.DELETE) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { iArkCommonService.deleteQueryFilter(item.getModelObject().getQueryFilter()); listEditor.removeItem(item); listEditor.updateModel(); target.add(form); } }.setDefaultFormProcessing(false).setVisible(item.getIndex() >= 0)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return listEditor; }
From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java
/** * @param ttl overwrite from ormobject/*w ww. j ava 2 s . c o m*/ */ public void pushObject(T ormobject, int ttl) throws InvalidClassException, ConnectionException { if (ormobject.key == null) { throw new NullPointerException("\"key\" can't to be null"); } ArrayList<Field> fields = getOrmobjectUsableFields(); for (int pos_df = 0; pos_df < fields.size(); pos_df++) { try { pushColumn(ormobject.key, ttl, fields.get(pos_df).getName(), this.reference.getField(fields.get(pos_df).getName()).get(ormobject)); } catch (IllegalAccessException e) { Log2Dump dump = new Log2Dump(); dump.add("ormobject", ormobject); dump.add("ormobject.class", ormobject.getClass()); dump.add("fields.name", fields.get(pos_df).getName()); Log2.log.error("Grave problem with ORM object", e, dump); } catch (NoSuchFieldException e) { e.printStackTrace(); } } }
From source file:io.konik.utils.RandomInvoiceGenerator.java
private Object createNewInstance(Class<?> root) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { try {//from w w w .jav a 2 s . c o m if (root.isArray()) { Object[] array = (Object[]) Array.newInstance(root.getComponentType(), 1); Class<?> componentType = root.getComponentType(); array[0] = populteData(componentType, componentType.getName()); return array; } return root.newInstance(); } catch (IllegalAccessException e) { Constructor<?> biggestConstructor = findBiggestConstructor(root); //for each parameter populate data Class<?>[] constructorParameters = biggestConstructor.getParameterTypes(); Object[] constructorParameterObjects = new Object[constructorParameters.length]; for (int i = 0; i < constructorParameters.length; i++) { Class<?> cp = constructorParameters[i]; constructorParameterObjects[i] = populteData(cp, biggestConstructor.getName()); } return biggestConstructor.newInstance(constructorParameterObjects); } catch (InstantiationException e) { if (root.equals(CommonTax.class)) { // return ZfDateFactory.create(supportedDateFormatts[random.nextInt(3)]); } // throw e; e.printStackTrace(); return null; } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void requestPermissions(int requestCode, String[] action) { try {//from w ww . ja v a 2s. co m Method methodToFind = cordova.getClass().getMethod("requestPermissions", CordovaPlugin.class, int.class, String[].class); if (methodToFind != null) { try { methodToFind.invoke(cordova, this, requestCode, action); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } catch (NoSuchMethodException e) { e.printStackTrace(); } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private boolean hasPermission(String action) { try {//from w w w . ja va2 s.c om Method methodToFind = cordova.getClass().getMethod("hasPermission", String.class); if (methodToFind != null) { try { return (Boolean) methodToFind.invoke(cordova, action); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } catch (NoSuchMethodException e) { // Probably SDK < 23 (MARSHMALLOW implmements fine-grained, user-controlled permissions). return true; } return true; }
From source file:com.arkami.myidkey.activity.KeyCardEditActivity.java
/** * searches for a difference between the list of files in the database and * the one that this key card have// w ww . ja va2 s . c om */ private void updateFiles() { if (keyCard.getFileIds() != null) { Arrays.sort(keyCard.getFileIds()); try { long[] inDB = keyCardDataSource.getFileIds(keyCard.getId()); boolean deleteThisFile; Arrays.sort(inDB); for (int i = 0; i < inDB.length; i++) { deleteThisFile = true; for (int j = 0; j < keyCard.getFileIds().length; j++) { if (inDB[i] == keyCard.getFileIds()[j]) { deleteThisFile = false; break; } } if (deleteThisFile) { fileDataSource.delete(inDB[i]); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } }
From source file:phex.prefs.OldCfg.java
private boolean deserialiseMap(Field myField) { boolean isMap = false; try {/*w w w. ja va 2s .c o m*/ if (myField.getType().getName().equals("java.util.HashMap")) { myField.set(this, new HashMap()); // create an empty list Map myMap = (Map) myField.get(this); String key; String prefix = myField.getName() + LIST_PREFIX; for (Enumeration e = mSetting.propertyNames(); e.hasMoreElements();) { String foundName = (String) e.nextElement(); if (foundName.startsWith(prefix)) { key = foundName.substring(prefix.length()); if (key.length() > 0 && mSetting.getProperty(foundName).length() > 0) { myMap.put(key, mSetting.getProperty(foundName)); } } } isMap = true; // successfully processed the list } } catch (IllegalAccessException ex) { ex.printStackTrace(); isMap = false; } return isMap; }
From source file:com.arkami.myidkey.activity.KeyCardEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.w("onCreate", "called"); super.onCreate(savedInstanceState); setContentView(R.layout.key_card);/*from ww w . ja va 2 s.c o m*/ typeArrows = (ImageView) findViewById(R.id.key_card_type_arrows); if (savedInstanceState != null) { photoUri = savedInstanceState.getParcelable("photoUri"); keyCard = savedInstanceState.getParcelable("keyCard"); isInEditMode = savedInstanceState.getBoolean(IS_IN_EDIT_MODE, false); } isInEditMode = getIntent().getBooleanExtra(IS_IN_EDIT_MODE, false); // this.keyCard = Service.getInstance(this).getKeyCard(keyCardId); this.keyCardDataSource = new KeyCardDataSource(this); this.valuesDataSource = new ValuesDataSource(this); this.fileDataSource = new FileDataSource(this); this.tagDataSource = new TagDataSource(this); bottom = (LinearLayout) findViewById(R.id.key_card_specific_items_layout); long keyCardId = this.getIntent().getLongExtra(KEY_CARD_ID, -1); if (keyCardId == -1) { keyCard = new KeyCard(); } else { try { this.keyCard = keyCardDataSource.get(keyCardId); } catch (IllegalAccessException e) { e.printStackTrace(); Toast.makeText(this, "No such keycard found in database.", Toast.LENGTH_LONG).show(); this.finish(); } } Log.w("Selected key card: ", keyCard.toString()); keyCardName = (EditText) findViewById(R.id.key_card_name_edit_text); keyCardName.setText(keyCard.getName()); // this.selectTagDialog = new TagDialog(KeyCardEditActivity.this, KeyCardEditActivity.this); selectedTags = (LinearLayout) findViewById(R.id.key_card_tags_selected); initializeTagSpinner(); // initFavourite(); keyCardTypeDataSource = new KeyCardTypesDataSource(this); keyCardTypeDataSource.open(); if (keyCard.getKeyCardTypeId() == null) { keyCard.setKeyCardTypeId(1L); } KeyCardType keyCardType = keyCardTypeDataSource.getTypeById(keyCard.getKeyCardTypeId()); // Cache.getInstance(this) // .getKeyCardTypeEnum(keyCard.getKeyCardTypeId()).getTitle(); this.componentHolder = new CustomComponentHolder(this); initializeTypeSpinner(keyCardType); initializeFilesLists(); initializeBottom(); setDeleteButton(); if ((keyCard.getValueIds() == null) || (keyCard.getValueIds().length < 1) || (isInEditMode)) { setKeyCardActionbarEdit(); } else { setKeyCardActionbarView(); } }