Example usage for java.lang IllegalAccessException getCause

List of usage examples for java.lang IllegalAccessException getCause

Introduction

In this page you can find the example usage for java.lang IllegalAccessException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:com.ixcode.framework.javabean.format.JavaBeanFormatter.java

public String getPropertyValueAsString(Object javaBean, String propertyName, Locale locale)
        throws FormatterException {
    try {// w  ww . j a  va 2s  .  co  m
        Object value = PropertyUtils.getProperty(javaBean, propertyName);

        String formatted;

        if (value instanceof String) {
            formatted = (String) value;
        } else if (value == null) {
            formatted = "";
        } else {
            Class propertyType = IntrospectionUtils.getPropertyType(javaBean, propertyName);
            IJavaBeanValueFormat format = getFormat(locale, propertyType);
            formatted = format.format(value);

        }

        return formatted;

    } catch (IllegalAccessException e) {
        throw new FormatterException(IntrospectionUtils.getJavaBeanName(javaBean), e);
    } catch (InvocationTargetException e) {
        throw new FormatterException(IntrospectionUtils.getJavaBeanName(javaBean), e.getCause());
    } catch (NoSuchMethodException e) {
        throw new FormatterException(IntrospectionUtils.getJavaBeanName(javaBean), e);
    } catch (JavaBeanException e) {
        throw new FormatterException(IntrospectionUtils.getJavaBeanName(javaBean), e);
    }
}

From source file:org.sipfoundry.sipxconfig.bulk.ldap.UserMapper.java

private void setProperty(User user, Attributes attrs, Index index) throws NamingException {
    try {//from  w  w  w .java2s . c  o m
        String value = getValue(attrs, index);
        if (value != null) {
            BeanUtils.setProperty(user, index.getName(), value);
        }
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e.getCause());
    }
}

From source file:org.apache.camel.util.ObjectHelper.java

/**
 * A helper method to invoke a method via reflection and wrap any exceptions
 * as {@link RuntimeCamelException} instances
 *
 * @param method the method to invoke//  www. j  a v a2 s .  com
 * @param instance the object instance (or null for static methods)
 * @param parameters the parameters to the method
 * @return the result of the method invocation
 */
public static Object invokeMethod(Method method, Object instance, Object... parameters) {
    try {
        return method.invoke(instance, parameters);
    } catch (IllegalAccessException e) {
        throw new RuntimeCamelException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeCamelException(e.getCause());
    }
}

From source file:org.jboss.aerogear.cordova.oauth2.OauthGoogleServicesIntentHelper.java

private void getToken(final String accountName) {
    Runnable runnable = new Runnable() {
        public void run() {
            String token;//from   w ww.j  ava2  s  .  c o m
            try {
                Log.i(TAG, "Retrieving token for: " + accountName);
                Log.i(TAG, "with scope(s): " + scopes);
                token = (String) METHOD_getToken.invoke(null, cordova.getActivity(), accountName, scopes);
                callbackContext.success(token);
            } catch (InvocationTargetException ite) {
                Throwable userRecoverableException = ite.getCause();
                if (CLASS_UserRecoverableAuthException != null
                        && CLASS_UserRecoverableAuthException.isInstance(userRecoverableException)) {
                    try {
                        Intent intent = (Intent) METHOD_getIntent.invoke(userRecoverableException);
                        Log.e(TAG, "UserRecoverableAuthException: Attempting recovery...");
                        cordova.getActivity().startActivityForResult(intent, REQUEST_AUTHORIZATION);
                    } catch (IllegalAccessException e) {
                        Log.i(TAG, "error" + e.getMessage());
                        callbackContext.error("plugin failed to get token: " + e.getMessage());
                    } catch (InvocationTargetException e) {
                        Log.i(TAG, "error" + e.getCause().getMessage());
                        callbackContext.error("plugin failed to get token: " + e.getCause().getMessage());
                    }
                }
            } catch (Exception e) {
                Log.i(TAG, "error" + e.getMessage());
                callbackContext.error("plugin failed to get token: " + e.getMessage());
            }
        }
    };
    cordova.getThreadPool().execute(runnable);
}

From source file:com.francisli.processing.http.HttpClient.java

/**
 * @exclude//from   www.j a  v a 2 s.c  o m
 */
public void pre() throws Throwable {
    HashMap<HttpRequest, HttpResponse> requestMapClone;
    synchronized (this) {
        requestMapClone = (HashMap<HttpRequest, HttpResponse>) requestMap.clone();
    }
    for (HttpRequest request : requestMapClone.keySet()) {
        HttpResponse response = requestMapClone.get(request);
        try {
            callbackMethod.invoke(parent, new Object[] { request, response });
        } catch (IllegalAccessException ex) {

        } catch (IllegalArgumentException ex) {

        } catch (InvocationTargetException ex) {
            throw ex.getCause();
        }
        synchronized (this) {
            requestMap.remove(request);
        }
    }
}

From source file:com.anrisoftware.globalpom.reflection.beans.BeanAccessImpl.java

private boolean setValueWithSetter(Method setter, Object value) throws PropertyVetoException {
    if (setter == null) {
        return false;
    }/*from www  .  j a v a 2s .  c  om*/
    try {
        setter.invoke(bean, value);
        return true;
    } catch (IllegalAccessException e) {
        throw log.illegalAccessError(e, bean, fieldName, setter);
    } catch (IllegalArgumentException e) {
        throw log.illegalArgumentError(e, bean, fieldName, setter);
    } catch (InvocationTargetException e) {
        if (e.getCause() instanceof PropertyVetoException) {
            PropertyVetoException ex = (PropertyVetoException) e.getCause();
            throw log.unacceptableValueError(ex, bean, fieldName, setter);
        }
        throw log.invocationTargetError(e, bean, fieldName, setter);
    }
}

From source file:org.acegisecurity.vote.AclEntryVoter.java

public int vote(Authentication authentication, Object object, ConfigAttributeDefinition config) {
    Iterator iter = config.getConfigAttributes();

    while (iter.hasNext()) {
        ConfigAttribute attr = (ConfigAttribute) iter.next();

        if (this.supports(attr)) {
            // Need to make an access decision on this invocation
            // Attempt to locate the domain object instance to process
            Object domainObject = getDomainObjectInstance(object);

            // Evaluate if we are required to use an inner domain object
            if (domainObject != null && internalMethod != null && (!"".equals(internalMethod))) {
                try {
                    Class clazz = domainObject.getClass();
                    Method method = clazz.getMethod(internalMethod, new Class[] {});
                    domainObject = method.invoke(domainObject, new Object[] {});
                } catch (NoSuchMethodException nsme) {
                    throw new AuthorizationServiceException("Object of class '" + domainObject.getClass()
                            + "' does not provide the requested internalMethod: " + internalMethod);
                } catch (IllegalAccessException iae) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("IllegalAccessException", iae);

                        if (iae.getCause() != null) {
                            logger.debug("Cause: " + iae.getCause().getMessage(), iae.getCause());
                        }//www  . j av a 2  s  .co m
                    }

                    throw new AuthorizationServiceException("Problem invoking internalMethod: " + internalMethod
                            + " for object: " + domainObject);
                } catch (InvocationTargetException ite) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("InvocationTargetException", ite);

                        if (ite.getCause() != null) {
                            logger.debug("Cause: " + ite.getCause().getMessage(), ite.getCause());
                        }
                    }

                    throw new AuthorizationServiceException("Problem invoking internalMethod: " + internalMethod
                            + " for object: " + domainObject);
                }
            }

            // If domain object is null, vote to abstain
            if (domainObject == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Voting to abstain - domainObject is null");
                }

                return AccessDecisionVoter.ACCESS_ABSTAIN;
            }

            // Obtain the OID applicable to the domain object
            ObjectIdentity objectIdentity = objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);

            // Obtain the SIDs applicable to the principal
            Sid[] sids = sidRetrievalStrategy.getSids(authentication);

            Acl acl;

            try {
                // Lookup only ACLs for SIDs we're interested in
                acl = aclService.readAclById(objectIdentity, sids);
            } catch (NotFoundException nfe) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Voting to deny access - no ACLs apply for this principal");
                }

                return AccessDecisionVoter.ACCESS_DENIED;
            }

            try {
                if (acl.isGranted(requirePermission, sids, false)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Voting to grant access");
                    }

                    return AccessDecisionVoter.ACCESS_GRANTED;
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "Voting to deny access - ACLs returned, but insufficient permissions for this principal");
                    }

                    return AccessDecisionVoter.ACCESS_DENIED;
                }
            } catch (NotFoundException nfe) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Voting to deny access - no ACLs apply for this principal");
                }

                return AccessDecisionVoter.ACCESS_DENIED;
            }
        }
    }

    // No configuration attribute matched, so abstain
    return AccessDecisionVoter.ACCESS_ABSTAIN;
}

From source file:com.github.koraktor.steamcondenser.community.GameInventory.java

/**
 * Updates the contents of the backpack using Steam Web API
 *
 * @throws WebApiException on Web API errors
 *//* w  w  w  .j  av a  2  s  .co  m*/
public void fetch() throws SteamCondenserException {
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("SteamID", this.steamId64);
        JSONObject result = WebApi.getJSONData("IEconItems_" + this.getAppId(), "GetPlayerItems", 1, params);

        this.items = new HashMap<Integer, GameItem>();
        this.preliminaryItems = new ArrayList<GameItem>();
        JSONArray itemsData = result.getJSONArray("items");
        for (int i = 0; i < itemsData.length(); i++) {
            JSONObject itemData = itemsData.getJSONObject(i);
            if (itemData != null) {
                try {
                    GameItem item = this.getItemClass().getConstructor(this.getClass(), JSONObject.class)
                            .newInstance(this, itemData);
                    if (item.isPreliminary()) {
                        this.preliminaryItems.add(item);
                    } else {
                        this.items.put(item.getBackpackPosition() - 1, item);
                    }
                } catch (IllegalAccessException e) {
                } catch (InstantiationException e) {
                } catch (InvocationTargetException e) {
                    if (e.getCause() instanceof SteamCondenserException) {
                        throw (SteamCondenserException) e.getCause();
                    } else {
                        throw (RuntimeException) e.getCause();
                    }
                } catch (NoSuchMethodException e) {
                }
            }
        }
    } catch (JSONException e) {
        throw new WebApiException("Could not parse JSON data.", e);
    }

    this.fetchDate = new Date();
}

From source file:org.acegisecurity.vote.BasicAclEntryVoter.java

public int vote(Authentication authentication, Object object, ConfigAttributeDefinition config) {
    Iterator iter = config.getConfigAttributes();

    while (iter.hasNext()) {
        ConfigAttribute attr = (ConfigAttribute) iter.next();

        if (this.supports(attr)) {
            // Need to make an access decision on this invocation
            // Attempt to locate the domain object instance to process
            Object domainObject = getDomainObjectInstance(object);

            // If domain object is null, vote to abstain
            if (domainObject == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Voting to abstain - domainObject is null");
                }//from w w w.  j  ava  2  s. c  o  m

                return AccessDecisionVoter.ACCESS_ABSTAIN;
            }

            // Evaluate if we are required to use an inner domain object
            if ((internalMethod != null) && !"".equals(internalMethod)) {
                try {
                    Class clazz = domainObject.getClass();
                    Method method = clazz.getMethod(internalMethod, new Class[] {});
                    domainObject = method.invoke(domainObject, new Object[] {});
                } catch (NoSuchMethodException nsme) {
                    throw new AuthorizationServiceException("Object of class '" + domainObject.getClass()
                            + "' does not provide the requested internalMethod: " + internalMethod);
                } catch (IllegalAccessException iae) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("IllegalAccessException", iae);

                        if (iae.getCause() != null) {
                            logger.debug("Cause: " + iae.getCause().getMessage(), iae.getCause());
                        }
                    }

                    throw new AuthorizationServiceException("Problem invoking internalMethod: " + internalMethod
                            + " for object: " + domainObject);
                } catch (InvocationTargetException ite) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("InvocationTargetException", ite);

                        if (ite.getCause() != null) {
                            logger.debug("Cause: " + ite.getCause().getMessage(), ite.getCause());
                        }
                    }

                    throw new AuthorizationServiceException("Problem invoking internalMethod: " + internalMethod
                            + " for object: " + domainObject);
                }
            }

            // Obtain the ACLs applicable to the domain object
            AclEntry[] acls = aclManager.getAcls(domainObject, authentication);

            // If principal has no permissions for domain object, deny
            if ((acls == null) || (acls.length == 0)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Voting to deny access - no ACLs returned for this principal");
                }

                return AccessDecisionVoter.ACCESS_DENIED;
            }

            // Principal has some permissions for domain object, check them
            for (int i = 0; i < acls.length; i++) {
                // Locate processable AclEntrys
                if (acls[i] instanceof BasicAclEntry) {
                    BasicAclEntry processableAcl = (BasicAclEntry) acls[i];

                    // See if principal has any of the required permissions
                    for (int y = 0; y < requirePermission.length; y++) {
                        if (processableAcl.isPermitted(requirePermission[y])) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Voting to grant access");
                            }

                            return AccessDecisionVoter.ACCESS_GRANTED;
                        }
                    }
                }
            }

            // No permissions match
            if (logger.isDebugEnabled()) {
                logger.debug(
                        "Voting to deny access - ACLs returned, but insufficient permissions for this principal");
            }

            return AccessDecisionVoter.ACCESS_DENIED;
        }
    }

    // No configuration attribute matched, so abstain
    return AccessDecisionVoter.ACCESS_ABSTAIN;
}

From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.DataLollipopAction.java

@Override
protected void performActionOff() {
    new AsyncTask<Void, Void, Void>() {
        @Override//from  w  w w . j a v  a  2  s . c om
        protected Void doInBackground(Void... args) {
            try {
                mToggleDataMethod.invoke(mTelephonyManager, false);
            } catch (IllegalAccessException e) {
                Log.e(TAG, "Inaccessible data toggle method");
            } catch (IllegalArgumentException e) {
                Log.e(TAG, "Invalid data toggle method signature");
            } catch (InvocationTargetException e) {
                e.printStackTrace();
                Log.e(TAG, "Invalid data toggle method invocation target: " + e.getCause().getMessage());
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(mBroadcastIntent);
        }

    }.execute();
}