List of usage examples for java.lang IllegalAccessException getMessage
public String getMessage()
From source file:com.impetus.kundera.property.accessor.ObjectAccessor.java
public Object getInstance(Class<?> clazz) { Object o = null;/*from w ww .ja va2s. c o m*/ try { o = clazz.newInstance(); return o; } catch (InstantiationException ie) { log.warn("Instantiation exception,caused by :" + ie.getMessage()); return null; } catch (IllegalAccessException iae) { log.warn("Illegal access exception,caused by :" + iae.getMessage()); return null; } }
From source file:nl.b3p.commons.taglib.ImgBeanTag.java
/** * Render the end of the IMG tag./*from w ww . j av a 2 s . com*/ * * @exception JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { // Calculate page from bean, if present and no page attribute if (blink != null && bpage != null) { // Retrieve the required property try { Object bean = pageContext.findAttribute(blink); page = (String) PropertyUtils.getProperty(bean, bpage); if (page == null) { return (EVAL_PAGE); } } catch (IllegalAccessException e) { throw new JspException("No access: " + e.getMessage()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw new JspException("No result: " + e.getMessage()); } catch (NoSuchMethodException e) { throw new JspException("No method: " + e.getMessage()); } catch (Exception e) { } } // Evaluate the remainder of this page return super.doEndTag(); }
From source file:com.liferay.portal.servlet.SharedServletWrapper.java
public void init(ServletConfig sc) throws ServletException { super.init(sc); ServletContext ctx = getServletContext(); _servletContextName = StringUtil.replace(ctx.getServletContextName(), StringPool.SPACE, StringPool.UNDERLINE);//www. j a v a 2s . co m _servletClass = sc.getInitParameter("servlet-class"); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { _servletInstance = (Servlet) contextClassLoader.loadClass(_servletClass).newInstance(); } catch (ClassNotFoundException cnfe) { throw new ServletException(cnfe.getMessage()); } catch (IllegalAccessException iae) { throw new ServletException(iae.getMessage()); } catch (InstantiationException ie) { throw new ServletException(ie.getMessage()); } if (_servletInstance instanceof HttpServlet) { _httpServletInstance = (HttpServlet) _servletInstance; _httpServletInstance.init(sc); } else { _servletInstance.init(sc); } }
From source file:com.orange.mmp.api.ws.jsonrpc.SimpleListSerializer.java
@SuppressWarnings("unchecked") @Override//from w w w .jav a 2s. c om public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { List list = null; try { try { try { if (clazz.isInterface()) { list = new java.util.ArrayList(); } else list = (List) clazz.newInstance(); } catch (ClassCastException cce) { throw new UnmarshallException("invalid unmarshalling Class " + cce.getMessage()); } } catch (IllegalAccessException iae) { throw new UnmarshallException("no access unmarshalling object " + iae.getMessage()); } } catch (InstantiationException ie) { throw new UnmarshallException("unable to instantiate unmarshalling object " + ie.getMessage()); } JSONArray jsa = (JSONArray) o; state.setSerialized(o, list); int i = 0; try { for (; i < jsa.length(); i++) { list.add(ser.unmarshall(state, null, jsa.get(i))); } } catch (UnmarshallException e) { throw new UnmarshallException("element " + i + " " + e.getMessage()); } catch (JSONException e) { throw new UnmarshallException("element " + i + " " + e.getMessage()); } return list; }
From source file:org.openhab.binding.homematic.internal.communicator.client.BaseHomematicClient.java
/** * Adds the battery info datapoint to the specified device if the device has * batteries.//from w w w . j a va2 s . c om */ protected void addBatteryInfo(HmDevice device) throws HomematicClientException { HmBattery battery = HmBatteryTypeProvider.getBatteryType(device.getType()); if (battery != null) { for (HmChannel channel : device.getChannels()) { if ("0".equals(channel.getNumber())) { try { logger.debug("Adding battery type to device {}: {}", device.getType(), battery.getInfo()); HmDatapoint dp = new HmDatapoint(); FieldUtils.writeField(dp, "name", "BATTERY_TYPE", true); FieldUtils.writeField(dp, "writeable", Boolean.FALSE, true); FieldUtils.writeField(dp, "valueType", 20, true); dp.setValue(battery.getInfo()); channel.addDatapoint(dp); } catch (IllegalAccessException ex) { throw new HomematicClientException(ex.getMessage(), ex); } } } } }
From source file:com.tonbeller.wcf.convert.EditCtrlConverter.java
/** * initializes the value attribute of element from a bean property. *///from w w w . j a va 2s. co m public void convert(Formatter formatter, Object bean, Element element) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { try { String model = EditCtrl.getModelReference(element); if (model.length() == 0) return; String type = EditCtrl.getType(element); FormatHandler handler = formatter.getHandler(type); if (handler == null) throw new FormatException("no handler found for type: " + type); Object value = PropertyUtils.getProperty(bean, model); String pattern = EditCtrl.getFormatString(element); String strValue = handler.format(value, pattern); EditCtrl.setValue(element, strValue); } catch (IllegalAccessException e) { XoplonNS.setAttribute(element, "error", e.getMessage()); throw e; } catch (NoSuchMethodException e) { XoplonNS.setAttribute(element, "error", e.getMessage()); throw e; } catch (InvocationTargetException e) { XoplonNS.setAttribute(element, "error", e.getMessage()); throw e; } catch (FormatException e) { XoplonNS.setAttribute(element, "error", e.getMessage()); throw e; } }
From source file:org.projectforge.core.ConfigXml.java
/** * Copies only not null values of the configuration. *//*from w w w . j a v a2 s. c o m*/ private static void copyDeclaredFields(final String prefix, final Class<?> srcClazz, final Object src, final Object dest, final String... ignoreFields) { final Field[] fields = srcClazz.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (final Field field : fields) { if (ignoreFields != null && ArrayUtils.contains(ignoreFields, field.getName()) == false && accept(field)) { try { final Object srcFieldValue = field.get(src); if (srcFieldValue == null) { // Do nothing } else if (srcFieldValue instanceof ConfigurationData) { final Object destFieldValue = field.get(dest); Validate.notNull(destFieldValue); final StringBuffer buf = new StringBuffer(); if (prefix != null) { buf.append(prefix); } String alias = null; if (field.isAnnotationPresent(XmlField.class)) { final XmlField xmlFieldAnn = field.getAnnotation(XmlField.class); if (xmlFieldAnn != null) { alias = xmlFieldAnn.alias(); } } if (alias != null) { buf.append(alias); } else { buf.append(field.getClass().getName()); } buf.append("."); copyDeclaredFields(buf.toString(), srcFieldValue.getClass(), srcFieldValue, destFieldValue, ignoreFields); } else if (PLUGIN_CONFIGS_FIELD_NAME.equals(field.getName()) == true) { // Do nothing. } else { field.set(dest, srcFieldValue); if (StringHelper.isIn(field.getName(), "receiveSmsKey", "phoneLookupKey") == true) { log.info(StringUtils.defaultString(prefix) + field.getName() + " = ****"); } else { log.info(StringUtils.defaultString(prefix) + field.getName() + " = " + srcFieldValue); } } } catch (final IllegalAccessException ex) { throw new InternalError("Unexpected IllegalAccessException: " + ex.getMessage()); } } } final Class<?> superClazz = srcClazz.getSuperclass(); if (superClazz != null) { copyDeclaredFields(prefix, superClazz, src, dest, ignoreFields); } }
From source file:org.jaffa.soa.dataaccess.DataTransformer.java
/** * Take a source object and try and mold it back it its domain object * * @param path The path of this object being processed. This identifies possible parent and/or indexed entries where this object is contained. * @param source Source object to mould from, typically a GraphDataObject * @param uow Transaction handle all creates/update will be performed within. Throws an exception if null. * @param handler Possible bean handler to be used when processing this source object graph * @return In VALIDATE_ONLY mode the source object will be returned with default data. Else a GraphDataObject with just the key-fields of the root object will be returned if that object was newly created. Else a null will be returned. * @throws ApplicationExceptions Thrown if one or more application logic errors are generated during moulding * @throws FrameworkException Thrown if any runtime moulding error has occured. *//*w ww. ja va 2s . c om*/ private static GraphDataObject updateGraph(String path, GraphDataObject source, UOW uow, ITransformationHandler handler, Mode mode, GraphDataObject newGraph) throws ApplicationExceptions, FrameworkException { if (log.isDebugEnabled()) log.debug("Update Bean " + path); if (source.getDeleteObject() != null && source.getDeleteObject()) { if (mode == Mode.VALIDATE_ONLY) { if (log.isDebugEnabled()) log.debug( "The 'deleteObject' property is true. No prevalidations will be performed. The input object will be returned as is."); return source; } else { if (log.isDebugEnabled()) log.debug("The 'deleteObject' property is true. Invoking deleteGraph()"); deleteGraph(path, source, uow, handler); return null; } } else { try { IPersistent domainObject = null; GraphMapping mapping = MappingFactory.getInstance(source); Map keys = new LinkedHashMap(); Class doClass = mapping.getDomainClass(); // Get the key fields used in the domain object // In CLONE mode, get the keys from the new graph, and force the creation of the domain object boolean gotKeys = false; if (mode == Mode.CLONE) { if (newGraph != null) gotKeys = TransformerUtils.fillInKeys(path, newGraph, mapping, keys); } else gotKeys = TransformerUtils.fillInKeys(path, source, mapping, keys); // read DO based on key if (gotKeys) { // get the method on the DO to read via PK Method[] ma = doClass.getMethods(); Method findByPK = null; for (int i = 0; i < ma.length; i++) { if (ma[i].getName().equals("findByPK")) { if (ma[i].getParameterTypes().length == (keys.size() + 1) && (ma[i].getParameterTypes())[0] == UOW.class) { // Found with name and correct no. of input params findByPK = ma[i]; break; } } } if (findByPK == null) throw new ApplicationExceptions( new DomainObjectNotFoundException(TransformerUtils.findDomainLabel(doClass))); // Build input array Object[] inputs = new Object[keys.size() + 1]; { inputs[0] = uow; int i = 1; for (Iterator it = keys.values().iterator(); it.hasNext(); i++) { inputs[i] = it.next(); } } // Find Object based on key domainObject = (IPersistent) findByPK.invoke(null, inputs); if (domainObject != null && mode == Mode.CLONE) throw new ApplicationExceptions( new DuplicateKeyException(TransformerUtils.findDomainLabel(doClass))); } else { if (log.isDebugEnabled()) log.debug("Object " + path + " has either missing or null key values - Assume Create is needed"); } // Create object if not found boolean createMode = false; if (domainObject == null) { // In MASS_UPDATE mode, error if DO not found if (mode == Mode.MASS_UPDATE) throw new ApplicationExceptions( new DomainObjectNotFoundException(TransformerUtils.findDomainLabel(doClass))); // NEW OBJECT, create and reflect keys if (log.isDebugEnabled()) log.debug("DO '" + mapping.getDomainClassShortName() + "' not found with key, create a new one..."); domainObject = (IPersistent) doClass.newInstance(); // set the key fields for (Iterator it = keys.keySet().iterator(); it.hasNext();) { String keyField = (String) it.next(); if (mapping.isReadOnly(keyField)) continue; Object value = keys.get(keyField); TransformerUtils.updateProperty(mapping.getDomainFieldDescriptor(keyField), value, domainObject); } createMode = true; } else { if (log.isDebugEnabled()) log.debug("Found DO '" + mapping.getDomainClassShortName() + "' with key,"); } // Now update all domain fields TransformerUtils.updateBeanData(path, source, uow, handler, mapping, domainObject, mode, newGraph); // Invoke the changeDone trigger if (handler != null && handler.isChangeDone()) { for (ITransformationHandler transformationHandler : handler.getTransformationHandlers()) { transformationHandler.changeDone(path, source, domainObject, uow); } } // Return an appropriate output if (mode == Mode.VALIDATE_ONLY) { // In VALIDATE_ONLY mode, return the input graph (with defaulted data) return source; } else if (createMode) { // In create-mode, Create a new graph and stamp just the keys GraphDataObject outputGraph = source.getClass().newInstance(); for (Iterator i = keys.keySet().iterator(); i.hasNext();) { String keyField = (String) i.next(); PropertyDescriptor pd = mapping.getDomainFieldDescriptor(keyField); if (pd != null && pd.getReadMethod() != null) { Method m = pd.getReadMethod(); if (!m.isAccessible()) m.setAccessible(true); Object value = m.invoke(domainObject, (Object[]) null); AccessibleObject accessibleObject = mapping.getDataMutator(keyField); setValue(accessibleObject, outputGraph, value); } else { TransformException me = new TransformException(TransformException.NO_KEY_ON_OBJECT, path, keyField, source.getClass().getName()); log.error(me.getLocalizedMessage()); throw me; } } return outputGraph; } else { // In update-mode, return a null return null; } } catch (IllegalAccessException e) { TransformException me = new TransformException(TransformException.ACCESS_ERROR, path, e.getMessage()); log.error(me.getLocalizedMessage(), e); throw me; } catch (InvocationTargetException e) { ApplicationExceptions appExps = ExceptionHelper.extractApplicationExceptions(e); if (appExps != null) throw appExps; FrameworkException fe = ExceptionHelper.extractFrameworkException(e); if (fe != null) throw fe; TransformException me = new TransformException(TransformException.INVOCATION_ERROR, path, e); log.error(me.getLocalizedMessage(), me.getCause()); throw me; } catch (InstantiationException e) { TransformException me = new TransformException(TransformException.INSTANTICATION_ERROR, path, e.getMessage()); log.error(me.getLocalizedMessage(), e); throw me; } } }
From source file:info.magnolia.ui.form.field.definition.FieldDefinitionKeyGenerator.java
/** * TODO - this method has to be considered to be added to the parent class API. * @see <a href="http://jira.magnolia-cms.com/browse/MGNLUI-2824/> *//* w w w . java 2 s . c om*/ private String getParentName(Object parent) { try { Method getNameMethod = parent.getClass().getMethod("getName"); return (String) getNameMethod.invoke(parent); } catch (IllegalAccessException e) { log.warn("Cannot obtain name of parent object: " + e.getMessage()); } catch (SecurityException e) { log.warn("Cannot obtain name of parent object: " + e.getMessage()); } catch (NoSuchMethodException e) { log.warn("Cannot obtain name of parent object: " + e.getMessage()); } catch (IllegalArgumentException e) { log.warn("Cannot obtain name of parent object: " + e.getMessage()); } catch (InvocationTargetException e) { log.warn("Cannot obtain name of parent object: " + e.getMessage()); } return null; }
From source file:org.apache.sshd.common.file.nativefs.ExtendedNativeFileSystemView.java
public final String getCurrDir() { try {/* ww w.jav a 2 s. c o m*/ return ExtendedFieldUtils.readTypedField(currDirField, this, String.class); } catch (IllegalAccessException e) { throw new IllegalStateException( "Failed (" + e.getClass().getSimpleName() + ") to read currDir: " + e.getMessage(), e); } }