Example usage for java.lang.reflect InvocationTargetException getMessage

List of usage examples for java.lang.reflect InvocationTargetException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.sonar.ide.eclipse.ui.internal.wizards.associate.ConfigureProjectsPage.java

private void scheduleAutomaticAssociation() {
    getShell().addShellListener(new ShellAdapter() {
        @Override//from   www. j a v a 2s.  c  o m
        public void shellActivated(ShellEvent shellevent) {
            if (!alreadyRun) {
                alreadyRun = true;
                try {
                    if (sonarServers.isEmpty()) {
                        setMessage("Please configure a SonarQube server first", IMessageProvider.ERROR);
                    } else {
                        setMessage("", IMessageProvider.NONE);
                        getWizard().getContainer().run(true, false,
                                new AssociateProjects(sonarServers, getProjects()));
                    }
                } catch (InvocationTargetException ex) {
                    LOG.error(ex.getMessage(), ex);
                    if (ex.getTargetException() instanceof ConnectionException) {
                        setMessage(
                                "One of your SonarQube server cannot be reached. Please check your connection settings.",
                                IMessageProvider.ERROR);
                    } else {
                        setMessage("Error: " + ex.getMessage(), IMessageProvider.ERROR);
                    }
                } catch (Exception ex) {
                    LOG.error(ex.getMessage(), ex);
                    setMessage("Error: " + ex.getMessage(), IMessageProvider.ERROR);
                }
            }
        }
    });
}

From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java

@Override
protected void okPressed() {
    if (invalidWidgetValue(cboLayer, schemaTable) || selectedFields == null || selectedFields.length() == 0) {
        openInformation(getShell(), Messages.Task_ParameterRequired);
        return;// www .j  ava2  s.  com
    }

    if (inputLayer.getFilter() != Filter.EXCLUDE) {
        map.select(Filter.EXCLUDE, inputLayer);
    }

    try {
        PlatformUI.getWorkbench().getProgressService().run(false, true, this);
    } catch (InvocationTargetException e) {
        MessageDialog.openError(getShell(), Messages.General_Error, e.getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openInformation(getShell(), Messages.General_Cancelled, e.getMessage());
    }
}

From source file:org.josso.selfservices.password.PasswordManagementServiceImpl.java

public ProcessResponse handleRequest(ProcessRequest request) throws PasswordManagementException {

    String processId = request.getProcessId();
    String actionName = null;/*  w w w  . j  a va2  s. co  m*/

    if (log.isDebugEnabled())
        log.debug("Handling request for process [" + processId + "]");

    try {

        PasswordManagementProcess p = runningProcesses.get(processId);
        if (p == null)
            throw new PasswordManagementException("No such process " + processId);

        String nextStep = p.getState().getNextStep();

        if (log.isDebugEnabled())
            log.debug("Handling request for process [" + processId + "]");

        Method[] methods = p.getClass().getMethods();
        for (Method method : methods) {

            if (log.isDebugEnabled())
                log.debug("Processing method : " + method.getName());

            if (!method.isAnnotationPresent(Action.class))
                continue;

            Action action = method.getAnnotation(Action.class);

            if (log.isDebugEnabled())
                log.debug("Processing method annotation : " + action);

            for (String actionStep : action.fromSteps()) {

                if (log.isDebugEnabled())
                    log.debug("Processing annotation step : " + actionStep);

                if (actionStep.equals(nextStep)) {
                    actionName = method.getName();

                    if (log.isDebugEnabled())
                        log.debug("Dispatching request from step " + nextStep + " to process [" + processId
                                + "] action " + actionName);

                    // Store response next step in process state :
                    ProcessResponse r = (ProcessResponse) method.invoke(p, request);
                    ((BaseProcessState) p.getState()).setNextStep(r.getNextStep());
                    return r;
                }
            }

        }

        throw new PasswordManagementException("Step [" + nextStep + "] not supported by process");

    } catch (InvocationTargetException e) {
        throw new PasswordManagementException(
                "Cannot invoke process action [" + actionName + "] : " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
        throw new PasswordManagementException(
                "Cannot invoke process action [" + actionName + "] : " + e.getMessage(), e);
    }

}

From source file:de.micromata.genome.util.bean.PrivateBeanUtils.java

/**
 * Invokes a static method./*from ww w  . ja va2s.  c  o m*/
 *
 * @param clazz the clazz
 * @param method the method
 * @param args the args
 * @return return value of method call
 * @throws RuntimeException if bean is null, method cannot be found
 */
public static Object invokeStaticMethod(Class<?> clazz, String method, Object... args) {
    Method m = findMethod(null, clazz, method, args);
    if (m == null) {
        throw new RuntimeException(
                "Canot find method to call: " + clazz.getName() + "." + method + getArgsDescriptor(args));
    }
    AccessibleScope ascope = new AccessibleScope(m);
    try {
        return m.invoke(null, args);
    } catch (InvocationTargetException ex) {
        if (ex.getTargetException() instanceof RuntimeException) {
            throw (RuntimeException) ex.getTargetException();
        }
        throw new RuntimeException(
                "Failure calling method: " + clazz.getName() + "." + method + ": " + ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new RuntimeException(
                "Failure calling method: " + clazz.getName() + "." + method + ": " + ex.getMessage(), ex);
    } finally {
        ascope.restore();
    }
}

From source file:org.locationtech.udig.processingtoolbox.tools.TextfileToPointDialog.java

@Override
protected void okPressed() {
    if (invalidWidgetValue(cboSource) || getTextColumns().isEmpty() || locationView.getFile().isEmpty()) {
        openInformation(getShell(), Messages.Task_ParameterRequired);
        return;/*from w ww  .jav a  2 s. c o m*/
    }

    // check geometry columns
    List<TextColumn> schema = getTextColumns();
    boolean containsX = false, containsY = false, containsGeometry = false;
    for (TextColumn column : schema) {
        if (column.isX()) {
            containsX = true;
        } else if (column.isY()) {
            containsY = true;
        } else if (column.isGeometry()) {
            containsGeometry = true;
        }
    }

    if (containsGeometry == false) {
        if (containsX == false || containsY == false) {
            openInformation(getShell(), Messages.TextfileToPointDialog_XYRequired);
            return;
        }
    }

    try {
        PlatformUI.getWorkbench().getProgressService().run(false, true, this);
        openInformation(getShell(), String.format(Messages.Task_Completed, locationView.getFile()));

        if (!StringHelper.isNullOrEmpty(error)) {
            if (MessageDialog.openConfirm(getShell(), windowTitle, Messages.Task_ConfirmErrorFile)) {
                String errorPath = saveErrorAsText();
                if (errorPath != null) {
                    openInformation(getShell(), String.format(Messages.Task_CheckFile, errorPath));
                }
            }
        }
    } catch (InvocationTargetException e) {
        MessageDialog.openError(getShell(), Messages.General_Error, e.getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openInformation(getShell(), Messages.General_Cancelled, e.getMessage());
    }
}

From source file:de.micromata.genome.util.bean.PrivateBeanUtils.java

/**
 * Invoke method./*ww  w.  ja va 2 s.c o  m*/
 *
 * @param bean the bean
 * @param method the method
 * @param args the args
 * @return the object
 */
public static Object invokeMethod(Object bean, Method method, Object... args) {
    AccessibleScope ascope = new AccessibleScope(method);
    try {
        return method.invoke(bean, args);
    } catch (InvocationTargetException ex) {
        if (ex.getTargetException() instanceof RuntimeException) {
            throw (RuntimeException) ex.getTargetException();
        }
        throw new RuntimeException("Failure calling method: " + bean.getClass().getName() + "."
                + method.getName() + ": " + ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new RuntimeException("Failure calling method: " + bean.getClass().getName() + "."
                + method.getName() + ": " + ex.getMessage(), ex);
    } finally {
        ascope.restore();
    }
}

From source file:org.talend.mdm.repository.utils.RepositoryResourceUtil.java

public static void initialize() {
    IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
    try {//www .  j  av a 2  s  .co m
        progressService.run(true, true, initializeProcess);
    } catch (InvocationTargetException e) {
        log.error(e.getMessage(), e);
    } catch (InterruptedException e) {
        log.error(e.getMessage(), e);
    }

}

From source file:com.snaplogic.snaps.uniteller.BaseService.java

@Override
protected void process(Document document, String inputViewName) {
    try {/*from   w w w  . jav  a 2s .  c  om*/
        AccountBean bean = account.connect();
        String UFSConfigFilePath = urlEncoder.validateAndEncodeURI(bean.getConfigFilePath(), PATTERN, null)
                .toString();
        String UFSSecurityFilePath = urlEncoder
                .validateAndEncodeURI(bean.getSecurityPermFilePath(), PATTERN, null).toString();
        /* instantiating USFCreationClient */
        Class<?> CustomUSFCreationClient = Class.forName(UFS_FOLIO_CREATION_CLIENT_PKG_URI);
        Constructor<?> constructor = CustomUSFCreationClient
                .getDeclaredConstructor(new Class[] { IUFSConfigMgr.class, IUFSSecurityMgr.class });
        Object USFCreationClientObj = constructor.newInstance(CustomUFSConfigMgr.getInstance(UFSConfigFilePath),
                CustomUFSSecurityMgr.getInstance(UFSSecurityFilePath));
        Method setAutoUpdatePsw = CustomUSFCreationClient.getDeclaredMethod("setAutoUpdatePsw", Boolean.TYPE);
        setAutoUpdatePsw.invoke(USFCreationClientObj, autoUpdatePsw);
        /* Preparing the request for USF */
        Object data;
        if (document != null && (data = document.get()) != null) {
            if (data instanceof Map) {
                Map<String, Object> map = (Map<String, Object>) data;
                Class<?> UFSRequest = Class.forName(getUFSReqClassType());
                Object UFSRequestObj = UFSRequest.newInstance();
                Object inputFieldValue = null;
                Calendar cal = Calendar.getInstance();
                for (Method method : UFSRequest.getDeclaredMethods()) {
                    if (isSetter(method)
                            && (inputFieldValue = map.get(method.getName().substring(3))) != null) {
                        try {
                            String paramType = method.getParameterTypes()[0].getName();
                            if (paramType.equalsIgnoreCase(String.class.getName())) {
                                method.invoke(UFSRequest.cast(UFSRequestObj), String.valueOf(inputFieldValue));
                            } else if (paramType.equalsIgnoreCase(Double.class.getSimpleName())) {
                                method.invoke(UFSRequest.cast(UFSRequestObj),
                                        Double.parseDouble(String.valueOf(inputFieldValue)));
                            } else if (paramType.equalsIgnoreCase(INT)) {
                                method.invoke(UFSRequest.cast(UFSRequestObj),
                                        Integer.parseInt(String.valueOf(inputFieldValue)));
                            } else if (paramType.equalsIgnoreCase(Calendar.class.getName())) {
                                try {
                                    cal.setTime(sdtf.parse(String.valueOf(inputFieldValue)));
                                } catch (ParseException pe1) {
                                    try {
                                        cal.setTime(sdf.parse(String.valueOf(inputFieldValue)));
                                    } catch (ParseException pe) {
                                        writeToErrorView(
                                                String.format(DATE_PARSER_ERROR, DATETIME_FORMAT, DATE_FORMAT),
                                                pe.getMessage(), ERROR_RESOLUTION, pe);
                                    }
                                }
                                method.invoke(UFSRequest.cast(UFSRequestObj), cal);
                            }
                        } catch (IllegalArgumentException iae) {
                            writeToErrorView(String.format(ILLEGAL_ARGS_EXE, method.getName()),
                                    iae.getMessage(), ERROR_RESOLUTION, iae);
                        } catch (InvocationTargetException ite) {
                            writeToErrorView(ite.getTargetException().getMessage(), ite.getMessage(),
                                    ERROR_RESOLUTION, ite);
                        }
                    }
                }
                /* Invoking the request over USFCreationClient */
                Object UFSResponseObj = null;
                Method creationClientMethod = CustomUSFCreationClient
                        .getMethod(getCamelCaseForMethod(resourceType), UFSRequest);
                try {
                    UFSResponseObj = creationClientMethod.invoke(USFCreationClientObj,
                            UFSRequest.cast(UFSRequestObj));
                } catch (IllegalArgumentException iae) {
                    writeToErrorView(String.format(ILLEGAL_ARGS_EXE, creationClientMethod.getName()),
                            iae.getMessage(), ERROR_RESOLUTION, iae);
                } catch (InvocationTargetException ite) {
                    writeToErrorView(ite.getTargetException().getMessage(), ite.getMessage(), ERROR_RESOLUTION,
                            ite);
                }
                if (null != UFSResponseObj) {
                    outputViews.write(documentUtility.newDocument(processResponseObj(UFSResponseObj)));
                    counter.inc();
                }
            } else {
                writeToErrorView(NO_DATA_ERRMSG, NO_DATA_WARNING, NO_DATA_REASON, NO_DATA_RESOLUTION);
            }
        }
    } catch (Exception ex) {
        writeToErrorView(ERRORMSG, ex.getMessage(), ERROR_RESOLUTION, ex);
    }
}

From source file:edu.umich.robot.soar.OLCommandManager.java

/**
 * Convert a wme in to a command instance for processing. If the command
 * returns from this, it is accepted and status is set as such.
 * /*  w  w  w  .  j a v a  2  s  .co  m*/
 * @param id
 * @return
 * @throws SoarCommandError
 */
public OLCommand newInstance(Identifier id) throws SoarCommandError {
    String name = id.GetAttribute();

    Class<? extends OLCommand> klass = commands.get(name);
    if (klass != null) {
        try {
            Constructor<? extends OLCommand> ctor = klass
                    .getConstructor(new Class<?>[] { Identifier.class, SoarAgent.class });
            OLCommand command = ctor.newInstance(id, agent);
            if (command != null)
                CommandStatus.ACCEPTED.addStatus(id);
            logger.debug(agentPrompt + command);
            return command;

        } catch (InvocationTargetException e) {
            if (e.getCause() instanceof SoarCommandError) {
                SoarCommandError sce = (SoarCommandError) e.getCause();
                CommandStatus.ERROR.addStatus(id, sce.getMessage());
                logger.error(sce.getMessage());
            }
            return null;
        } catch (NoSuchMethodException e) {
            logger.error(e.getMessage());
            return null;
        } catch (IllegalAccessException e) {
            logger.error(e.getMessage());
            return null;
        } catch (InstantiationException e) {
            logger.error(e.getMessage());
            return null;
        }
    }

    logger.warn("No such command: " + name);
    return null;
}

From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicCommand.java

/**
 * set this instance null properties with the passed configuration
 * @param src/*from www.  ja v a 2 s.  co  m*/
 */
public void copyConfigurationIntoCommand(final ImageMosaicConfiguration src) {

    final PropertyDescriptor[] srcProps = PropertyUtils.getPropertyDescriptors(src);
    for (PropertyDescriptor srcProp : srcProps) {
        final String name = srcProp.getName();
        if (RESERVED_PROPS.contains(name)) {
            continue;
        }
        final Object obj;
        try {
            obj = PropertyUtils.getProperty(this, name);
            if (obj == null) {
                // override
                PropertyUtils.setProperty(this, name, PropertyUtils.getProperty(src, name));
            }
        } catch (InvocationTargetException e) {
            if (LOGGER.isWarnEnabled())
                LOGGER.warn(e.getMessage());
        } catch (NoSuchMethodException e) {
            if (LOGGER.isWarnEnabled())
                LOGGER.warn(e.getMessage());
        } catch (IllegalAccessException e) {
            if (LOGGER.isWarnEnabled())
                LOGGER.warn(e.getMessage());
        }
    }

    copyDomainAttributes(src, this);
}