Example usage for java.lang IllegalAccessException getMessage

List of usage examples for java.lang IllegalAccessException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:ch.algotrader.adapter.ib.DefaultIBOrderMessageFactory.java

@Override
public Order createOrderMessage(SimpleOrder order, Contract contract) {

    com.ib.client.Order ibOrder = new com.ib.client.Order();
    ibOrder.m_totalQuantity = (int) order.getQuantity();
    ibOrder.m_action = IBUtil.getIBSide(order.getSide());
    ibOrder.m_orderType = IBUtil.getIBOrderType(order);
    ibOrder.m_transmit = true;//  w w  w.j  a v a 2 s  . c o  m

    // overwrite the default exchange (defined by SecurityFamily) in case a different exchange is defined on the order
    if (order.getExchange() != null) {
        contract.m_exchange = order.getExchange().getIbCode();
    }

    // handle a potentially defined account
    if (order.getAccount().getExtAccount() != null) {

        ibOrder.m_account = order.getAccount().getExtAccount();

        // handling for financial advisor account groups
    } else if (order.getAccount().getExtAccountGroup() != null) {

        ibOrder.m_faGroup = order.getAccount().getExtAccountGroup();
        ibOrder.m_faMethod = this.iBConfig.getFaMethod();

        //            long existingQuantity = 0;
        //            for (Position position : order.getSecurity().getPositions()) {
        //                existingQuantity += position.getQuantity();
        //            }
        //
        //            // evaluate weather the transaction is opening or closing
        //            boolean opening = false;
        //            if (existingQuantity > 0 && Side.SELL.equals(order.getSide())) {
        //                opening = false;
        //            } else if (existingQuantity <= 0 && Side.SELL.equals(order.getSide())) {
        //                opening = true;
        //            } else if (existingQuantity < 0 && Side.BUY.equals(order.getSide())) {
        //                opening = false;
        //            } else if (existingQuantity >= 0 && Side.BUY.equals(order.getSide())) {
        //                opening = true;
        //            }
        //
        //            ibOrder.m_faGroup = order.getAccount().getExtAccountGroup();
        //
        //            if (opening) {
        //
        //                // open by specifying the actual quantity
        //                ibOrder.m_faMethod = this.faOpenMethod;
        //
        //            } else {
        //
        //                // reduce by percentage
        //                ibOrder.m_faMethod = "PctChange";
        //                ibOrder.m_totalQuantity = 0; // bacause the order is percent based
        //                ibOrder.m_faPercentage = "-" + Math.abs(order.getQuantity() * 100 / (existingQuantity - order.getQuantity()));
        //            }

        // handling for financial advisor allocation profiles
    } else if (order.getAccount().getExtAllocationProfile() != null) {

        ibOrder.m_faProfile = order.getAccount().getExtAllocationProfile();
    }

    // add clearing information
    if (order.getAccount().getExtClearingAccount() != null) {
        ibOrder.m_clearingAccount = order.getAccount().getExtClearingAccount();
        ibOrder.m_clearingIntent = "Away";
    }

    //set the limit price if order is a limit order or stop limit order
    if (order instanceof LimitOrderI) {
        LimitOrderI limitOrder = (LimitOrderI) order;
        ibOrder.m_lmtPrice = PriceUtil.denormalizePrice(order, limitOrder.getLimit());
    }

    //set the stop price if order is a stop order or stop limit order
    if (order instanceof StopOrderI) {
        StopOrderI stopOrder = (StopOrderI) order;
        ibOrder.m_auxPrice = PriceUtil.denormalizePrice(order, stopOrder.getStop());
    }

    // set Time-In-Force (ATC are set as order types LOC and MOC)
    if (order.getTif() != null && !TIF.ATC.equals(order.getTif())) {
        ibOrder.m_tif = order.getTif().name();

        // set the TIF-Date
        if (order.getTifDateTime() != null) {
            ibOrder.m_goodTillDate = format.format(DateTimeLegacy.toLocalDateTime(order.getTifDateTime()));
        }
    }

    // separate properties that correspond to IB Order fields from the rest
    Map<String, OrderProperty> propertiesMap = new HashMap<>(order.getOrderProperties());
    for (Field field : FieldUtil.getAllFields(ibOrder.getClass())) {
        String name = field.getName().substring(2);
        OrderProperty orderProperty = propertiesMap.get(name);
        if (orderProperty != null && OrderPropertyType.IB.equals(orderProperty.getType())) {
            try {
                Object value = this.convertUtils.convert(orderProperty.getValue(), field.getType());
                field.set(ibOrder, value);
            } catch (IllegalAccessException e) {
                throw new ServiceException(e.getMessage(), e);
            }
            propertiesMap.remove(name);
        }
    }

    // add remaining params as AlgoParams
    Vector<TagValue> params = new Vector<>();
    for (OrderProperty orderProperty : propertiesMap.values()) {
        if (OrderPropertyType.IB.equals(orderProperty.getType())) {
            params.add(new TagValue(orderProperty.getName(), orderProperty.getValue()));
        }
    }

    if (params.size() > 0) {
        ibOrder.m_algoParams = params;
    }

    return ibOrder;
}

From source file:org.hyperic.hq.agent.server.monitor.AgentMonitorSimple.java

/**
 * Get a value of monitorKeys//from  ww w. j  av  a  2  s  . c  o m
 *
 * @param monitorKeys Keys that the monitor recognizes
 * @return A value for each monitorKey presented
 */
public AgentMonitorValue[] getMonitorValues(String[] monitorKeys) {
    Object[] noArgs = new Object[0];
    AgentMonitorValue[] res;

    res = new AgentMonitorValue[monitorKeys.length];
    for (int i = 0; i < monitorKeys.length; i++) {
        String key = monitorKeys[i];
        Method m = (Method) this.methodMap.get(key);
        AgentMonitorValue val;

        val = new AgentMonitorValue();
        if (m == null) {
            val.setErrCode(AgentMonitorValue.ERR_BADKEY);
        } else {
            try {
                Object invokeRes;
                Class resClass;

                invokeRes = m.invoke(this, noArgs);
                resClass = invokeRes.getClass();
                if (resClass.equals(String.class)) {
                    val.setValue((String) invokeRes);
                } else if (resClass.equals(Double.TYPE) || resClass.equals(Double.class)) {
                    val.setValue(((Double) invokeRes).doubleValue());
                } else if (resClass.equals(String[].class)) {
                    val.setValue((String[]) invokeRes);
                } else if (resClass.equals(int[].class)) {
                    val.setValue((int[]) invokeRes);
                } else {
                    throw new IllegalStateException("Unhandled res type: " + resClass);
                }
            } catch (IllegalAccessException exc) {
                this.log.error("Unable to access monitor method '" + key + "': " + exc.getMessage(), exc);
                val.setErrCode(AgentMonitorValue.ERR_INTERNAL);
            } catch (IllegalArgumentException exc) {
                // Should never occur
                this.log.error(
                        "Invalid arguments passed to monitor " + "method '" + key + "': " + exc.getMessage(),
                        exc);
                val.setErrCode(AgentMonitorValue.ERR_INTERNAL);
            } catch (InvocationTargetException exc) {
                Throwable tExc = exc.getTargetException();

                if (tExc instanceof AgentMonitorIncalculableException) {
                    val.setErrCode(AgentMonitorValue.ERR_INCALCULABLE);
                } else if (tExc instanceof AgentMonitorInternalException) {
                    val.setErrCode(AgentMonitorValue.ERR_INTERNAL);
                } else {
                    val.setErrCode(AgentMonitorValue.ERR_INTERNAL);
                    this.log.error(
                            "Monitor method '" + key + "' threw " + "a runtime exception: " + tExc.getMessage(),
                            tExc);
                }
            }
        }

        res[i] = val;
    }
    return res;
}

From source file:edu.brown.api.BenchmarkConfig.java

@Override
public String toString() {
    Class<?> confClass = this.getClass();
    final Map<String, Object> m0 = new ListOrderedMap<String, Object>();
    final Map<String, Object> m1 = new ListOrderedMap<String, Object>();
    final Map<String, Object> m2 = new ListOrderedMap<String, Object>();

    for (Field f : confClass.getFields()) {
        String key = f.getName().toUpperCase();
        if (key.equalsIgnoreCase("hosts")) {
            m0.put("Number of Hosts", this.hosts.length);
            m0.put("Hosts", StringUtil.join("\n", this.hosts));
        } else if (key.equalsIgnoreCase("clients")) {
            m1.put("Number of Clients", this.clients.length);
            m1.put("Clients", StringUtil.join("\n", this.clients));
        } else if (key.equalsIgnoreCase("clientParameters") || key.equalsIgnoreCase("siteParameters")) {
            // Skip
        } else {/*  w  ww  .j  a v a  2  s  . c o m*/
            Object val = null;
            try {
                val = f.get(this);
                if (ClassUtil.isArray(val))
                    val = Arrays.toString((Object[]) val);
            } catch (IllegalAccessException ex) {
                val = ex.getMessage();
            }
            if ((val instanceof HStoreConf) == false)
                m2.put(key, val);
        }
    } // FOR
    return (StringUtil.formatMaps(m0, m1, this.clientParameters, this.siteParameters, m2));
}

From source file:org.orekit.frames.TidalCorrectionTest.java

/**
 * Disables the internal TimeStampedCache for validation purposes.
 * For this purpose the newSlotInterval is set to a very low value (1 min), so that
 * every time new tidal correction data has to be created, a new slot is used.
 * @param tc the {@link TidalCorrection} object for which the cache shall be disabled
 *//*www . ja v a2  s .  co m*/
private void disableTimeStampedCache(final TidalCorrection tc) {
    try {
        Class<?> clazz = tc.getClass();
        Field field = clazz.getDeclaredField("cache");
        field.setAccessible(true);
        @SuppressWarnings("rawtypes")
        TimeStampedCache<?> cache = (TimeStampedCache) field.get(tc);
        clazz = cache.getClass();
        field = clazz.getDeclaredField("newSlotQuantumGap");
        field.setAccessible(true);
        field.set(cache, FastMath.round(60 / 1e-6));
    } catch (IllegalAccessException iae) {
        Assert.fail(iae.getMessage());
    } catch (NoSuchFieldException nfe) {
        Assert.fail(nfe.getMessage());
    }
}

From source file:com.taobao.android.builder.tasks.manager.MtlBaseTaskAction.java

protected void setFieldValueByReflection(Task task, String fieldName, Object value) {
    Field field = FieldUtils.getField(task.getClass(), fieldName, true);
    if (null == field) {
        throw new StopExecutionException(
                "The field with name:" + fieldName + " does not existed in class:" + task.getClass().getName());
    }//w w w.ja  v  a  2 s .  com
    try {
        FieldUtils.writeField(field, task, value, true);
    } catch (IllegalAccessException e) {
        throw new StopExecutionException(e.getMessage());
    }
}

From source file:org.cloudifysource.esc.util.InstallationDetailsBuilder.java

public InstallationDetailsBuilder clone() {
    InstallationDetailsBuilder copy = new InstallationDetailsBuilder();
    try {//from   w w  w .  j  a  v  a 2  s  .c om
        BeanUtils.copyProperties(copy, this);
    } catch (IllegalAccessException e) {
        // should not be possible
        throw new RuntimeException("Failed to clone existing installation details builder: " + e.getMessage(),
                e);
    } catch (InvocationTargetException e) {
        // should not be possible
        throw new RuntimeException("Failed to clone existing installation details builder: " + e.getMessage(),
                e);
    }
    return copy;
}

From source file:nonjsp.application.XmlXulRuleSet.java

public Object createObject(Attributes attributes) {
    Class cClass = null;//from  w  ww  .j  av  a 2 s . c  om
    UIComponent c = null;

    // Identify the name of the class to instantiate
    String className = attributes.getValue("class");
    String id = attributes.getValue("id");
    String value = attributes.getValue("value");

    // Instantiate the new object and return it
    try {
        cClass = Util.loadClass(className);
        c = (UIComponent) cClass.newInstance();
    } catch (ClassNotFoundException cnf) {
        throw new RuntimeException("Class Not Found:" + cnf.getMessage());
    } catch (InstantiationException ie) {
        throw new RuntimeException("Class Instantiation Exception:" + ie.getMessage());
    } catch (IllegalAccessException ia) {
        throw new RuntimeException("Illegal Access Exception:" + ia.getMessage());
    }

    c.setId(id);
    if (c instanceof UIOutput) {
        ((UIOutput) c).setValue(value);
    }
    return c;
}

From source file:nz.co.senanque.messaging.GenericEndpoint.java

private void unpackRoot(Element element, Object context) {
    ValidationSessionHolder validationSessonHolder = new ValidationSessionHolderImpl(getValidationEngine());
    validationSessonHolder.bind(context);
    try {/*from   ww  w.  j a va2  s.co  m*/
        @SuppressWarnings("unchecked")
        Iterator<Text> itr = (Iterator<Text>) element
                .getDescendants(new ContentFilter(ContentFilter.TEXT | ContentFilter.CDATA));
        while (itr.hasNext()) {
            Text text = itr.next();

            String name = getName(text);
            if (name.equals("id") || name.equals("version")) {
                continue;
            }
            try {
                Class<?> targetType = PropertyUtils.getPropertyType(context, name);
                Object value = ConvertUtils.convert(text.getValue(), targetType);
                PropertyUtils.setProperty(context, name, value);
                log.debug("name {} value {}", name, text.getValue());
            } catch (IllegalAccessException e) {
                // Ignore these and move on
                log.debug("{} {}", name, e.getMessage());
            } catch (InvocationTargetException e) {
                // Ignore these and move on
                log.debug("{} {}", name, e.getTargetException().toString());
            } catch (NoSuchMethodException e) {
                // Ignore these and move on
                log.debug("{} {}", name, e.getMessage());
            }
        }
    } finally {
        validationSessonHolder.close();
    }
}

From source file:com.alfresco.orm.ObjectFillHelper.java

public void getFilledObject(final NodeRef nodeRef, final AlfrescoORM alfrescoORM, boolean isLazy)
        throws ORMException {

    NodeService nodeService = serviceRegistry.getNodeService();
    if (!nodeService.exists(nodeRef)) {
        throw new ORMException("NodeRef does not exist : " + nodeRef);
    }/*from w  w w .  j  a v a 2 s .c o m*/
    Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
    List<Field> fields = new ArrayList<Field>();
    ReflectionUtil.getFields(alfrescoORM.getClass(), fields);

    for (Field field : fields) {
        if (field.isAnnotationPresent(AlfrescoQName.class)
                && !field.isAnnotationPresent(AlfrescoAssociation.class)) {
            AlfrescoQName alfrescoQName = field.getAnnotation(AlfrescoQName.class);
            QName qName = QName.createQName(alfrescoQName.namespaceURI(), alfrescoQName.localName());
            Method setterMethod = ReflectionUtil.setMethod(alfrescoORM.getClass(), field.getName());
            if (setterMethod.getParameterTypes().length == 0 || setterMethod.getParameterTypes().length > 1) {
                throw new ORMException("invalid method found for this tool : " + setterMethod.getName());
            }
            Class<?> classType = setterMethod.getParameterTypes()[0];
            Serializable value = properties.get(qName);
            try {
                setterMethod.invoke(alfrescoORM, getManipulatedValue(classType, value));
            } catch (IllegalAccessException e) {
                throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
            } catch (IllegalArgumentException e) {
                throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
            } catch (InvocationTargetException e) {
                throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
            }
        } else if (field.isAnnotationPresent(AlfrescoAspect.class)) {
            Method setterMethod = ReflectionUtil.setMethod(alfrescoORM.getClass(), field.getName());
            if (setterMethod.getParameterTypes().length == 0 || setterMethod.getParameterTypes().length > 1) {
                throw new ORMException("invalid method found for this tool : " + setterMethod.getName());
            }
            Class<?> classType = setterMethod.getParameterTypes()[0];
            try {
                AlfrescoORM alfrescoORMAspect = (AlfrescoORM) classType.newInstance();
                // setting the aspect to pojo
                setterMethod.invoke(alfrescoORM, alfrescoORMAspect);
                getFilledObject(nodeRef, alfrescoORMAspect, isLazy);
            } catch (InstantiationException e) {
                throw new ORMException(e.getMessage() + "class type: " + classType, e);
            } catch (IllegalAccessException e) {
                throw new ORMException(e.getMessage() + "class type: " + classType, e);
            } catch (IllegalArgumentException e) {
                throw new ORMException(e.getMessage() + "class type: " + classType, e);
            } catch (InvocationTargetException e) {
                throw new ORMException(e.getMessage() + "class type: " + classType, e);
            }
        } else if (field.isAnnotationPresent(AlfrescoAssociation.class)) {
            AlfrescoQName alfrescoQName = field.getAnnotation(AlfrescoQName.class);
            if (null == alfrescoQName) {
                throw new ORMException("please add alfresco quname aspect to the association");
            }
            QName qName = QName.createQName(alfrescoQName.namespaceURI(), alfrescoQName.localName());
            AlfrescoAssociation alfrescoAssociation = field.getAnnotation(AlfrescoAssociation.class);
            List<AssociationRef> associationRefs = nodeService.getTargetAssocs(nodeRef, qName);
            List<AlfrescoContent> associationList = new ArrayList<AlfrescoContent>();
            for (AssociationRef associationRef : associationRefs) {
                if (nodeService.exists(associationRef.getTargetRef())) {
                    try {
                        AlfrescoContent alfrescoORMForAssociation = null;
                        if (!isLazy) {
                            alfrescoORMForAssociation = alfrescoAssociation.type().newInstance();
                            getFilledObject(associationRef.getTargetRef(), alfrescoORMForAssociation, isLazy);
                        } else {
                            alfrescoORMForAssociation = LazyProxyFactoryBean.getLazyProxyFactoryBean()
                                    .getObject(associationRef.getTargetRef().getId(),
                                            alfrescoAssociation.type());
                        }
                        associationList.add(alfrescoORMForAssociation);

                    } catch (InstantiationException e) {
                        throw new ORMException(e.getMessage() + "class type: " + alfrescoAssociation.type(), e);
                    } catch (IllegalAccessException e) {
                        throw new ORMException(e.getMessage() + "class type: " + alfrescoAssociation.type(), e);
                    }

                } else {
                    // invalid association noderef found
                }
            }
            if (!associationList.isEmpty()) {
                Method setterMethod = ReflectionUtil.setMethod(alfrescoORM.getClass(), field.getName());
                if (alfrescoAssociation.many()) {
                    try {
                        setterMethod.invoke(alfrescoORM, associationList);
                    } catch (IllegalArgumentException e) {
                        throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
                    } catch (IllegalAccessException e) {
                        throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
                    } catch (InvocationTargetException e) {
                        throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
                    }
                } else {
                    try {
                        setterMethod.invoke(alfrescoORM, associationList.get(0));
                    } catch (IllegalArgumentException e) {
                        throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
                    } catch (IllegalAccessException e) {
                        throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
                    } catch (InvocationTargetException e) {
                        throw new ORMException(e.getMessage() + " method : " + setterMethod, e);
                    }
                }
            }
        }
    }

}

From source file:com.netflix.spinnaker.halyard.config.config.v1.HalconfigParser.java

/**
 * Deletes all files in the staging directory that are not referenced in the hal config.
 *///from  ww w.j  a  va  2 s .c  o m
public void cleanLocalFiles(Path stagingDirectoryPath) {
    if (!GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) {
        return;
    }
    Halconfig halconfig = getHalconfig();
    Set<String> referencedFiles = new HashSet<String>();
    Consumer<Node> fileFinder = n -> referencedFiles.addAll(n.localFiles().stream().map(f -> {
        try {
            f.setAccessible(true);
            return (String) f.get(n);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Failed to clean staging directory: " + e.getMessage(), e);
        } finally {
            f.setAccessible(false);
        }
    }).filter(Objects::nonNull).collect(Collectors.toSet()));
    halconfig.recursiveConsume(fileFinder);

    Set<String> existingStagingFiles = ((List<File>) FileUtils.listFiles(stagingDirectoryPath.toFile(),
            TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)).stream().map(f -> f.getAbsolutePath())
                    .collect(Collectors.toSet());

    existingStagingFiles.removeAll(referencedFiles);

    try {
        for (String f : existingStagingFiles) {
            FileUtils.forceDelete(new File(f));
        }
    } catch (IOException e) {
        throw new HalException(FATAL, "Failed to clean staging directory: " + e.getMessage(), e);
    }
}