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.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java

@Override
protected void okPressed() {
    if (invalidWidgetValue(cboLayer, cboField)) {
        openInformation(getShell(), Messages.Task_ParameterRequired);
        return;/*from   w  w  w.  j a  va 2s. c o  m*/
    }

    spatialConcept = (SpatialConcept) params.get(GlobalMoransIProcessFactory.spatialConcept.key);
    distanceMethod = (DistanceMethod) params.get(GlobalMoransIProcessFactory.distanceMethod.key);
    standardization = (StandardizationMethod) params.get(GlobalMoransIProcessFactory.standardization.key);
    searchDistance = (Double) params.get(GlobalMoransIProcessFactory.searchDistance.key);

    if (spatialConcept == SpatialConcept.FixedDistance && (searchDistance == null || searchDistance == 0)) {
        openInformation(getShell(), "FIXEDDISTANCEBAND option requires Distance Band"); //$NON-NLS-1$
        return;
    }

    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.kie.server.services.jbpm.JBPMKieContainerCommandServiceImpl.java

@Override
public ServiceResponsesList executeScript(CommandScript commands, MarshallingFormat marshallingFormat,
        String classType) {// w ww. j  a  va  2  s .  c o m
    List<ServiceResponse<? extends Object>> responses = new ArrayList<ServiceResponse<? extends Object>>();

    for (KieServerCommand command : commands.getCommands()) {
        if (!(command instanceof DescriptorCommand)) {
            logger.warn("Unsupported command '{}' given, will not process it", command.getClass().getName());
            continue;
        }

        boolean wrapResults = false;
        try {
            Object result = null;
            Object handler = null;

            DescriptorCommand descriptorCommand = (DescriptorCommand) command;
            // find out the handler to call to process given command
            if ("DefinitionService".equals(descriptorCommand.getService())) {
                handler = definitionServiceBase;
            } else if ("ProcessService".equals(descriptorCommand.getService())) {
                handler = processServiceBase;
            } else if ("UserTaskService".equals(descriptorCommand.getService())) {
                handler = userTaskServiceBase;
            } else if ("QueryService".equals(descriptorCommand.getService())) {
                handler = runtimeDataServiceBase;
            } else if ("JobService".equals(descriptorCommand.getService())) {
                handler = executorServiceBase;
            } else if ("QueryDataService".equals(descriptorCommand.getService())) {
                handler = queryDataServiceBase;
                // enable wrapping as in case of embedded objects jaxb does not properly parse it due to possible unknown types (List<?> etc)
                if (marshallingFormat.equals(MarshallingFormat.JAXB)) {
                    wrapResults = true;
                }
            } else if ("DocumentService".equals(descriptorCommand.getService())) {
                handler = documentServiceBase;
            } else if ("ProcessAdminService".equals(descriptorCommand.getService())) {
                handler = processAdminServiceBase;
            } else if ("UserTaskAdminService".equals(descriptorCommand.getService())) {
                handler = userTaskAdminServiceBase;
            } else {
                throw new IllegalStateException(
                        "Unable to find handler for " + descriptorCommand.getService() + " service");
            }

            List<Object> arguments = new ArrayList();
            // process and unwrap arguments
            for (Object arg : descriptorCommand.getArguments()) {
                logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg);
                if (arg instanceof Wrapped) {
                    arg = ((Wrapped) arg).unwrap();
                }
                logger.debug("After :: Argument with type {} and value {}", arg.getClass(), arg);
                arguments.add(arg);
            }

            if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) {
                arguments.add(descriptorCommand.getPayload());
            }
            if (descriptorCommand.getMarshallerFormat() != null
                    && !descriptorCommand.getMarshallerFormat().isEmpty()) {
                arguments.add(descriptorCommand.getMarshallerFormat());
            }

            logger.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(),
                    handler, arguments);
            // process command via reflection and handler
            result = MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray());
            logger.debug("Handler {} returned response {}", handler, result);

            if (wrapResults) {
                result = ModelWrapper.wrap(result);
                logger.debug("Wrapped response is {}", result);
            }
            // return successful result
            responses.add(new ServiceResponse(ServiceResponse.ResponseType.SUCCESS, "", result));
        } catch (InvocationTargetException e) {
            logger.error("Error while processing {} command", command, e);
            responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE,
                    e.getTargetException().getMessage()));
        } catch (Throwable e) {
            logger.error("Error while processing {} command", command, e);
            // return failure result
            responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getMessage()));
        }
    }
    logger.debug("About to return responses '{}'", responses);
    return new ServiceResponsesList(responses);
}

From source file:org.kuali.coeus.common.budget.framework.query.QueryList.java

/**
 * sorts the QueryList by the fieldName in ascending or descending order.
 * Note: the field Object should be of Comparable type.
 * @return boolean indicating whether the sort is completed successfully or not.
 * @param ignoreCase use only when comparing strings. as default implementation uses case sensitive comparison.
 * @param fieldName field which is used to sort the bean.
 * @param ascending if true sorting is done in ascending order,
 * else sorting is done in descending order.
 *///w  ww.  j a va  2s.co  m
@SuppressWarnings("rawtypes")
public boolean sort(String fieldName, boolean ascending, boolean ignoreCase) {
    Object current, next;
    int compareValue = 0;
    Field field = null;
    Method method = null;
    if (this.size() == 0) {
        return false;
    }
    Class dataClass = get(0).getClass();
    String methodName = null;
    try {
        field = dataClass.getDeclaredField(fieldName);
        if (!field.isAccessible()) {
            throw new NoSuchFieldException();
        }
    } catch (NoSuchFieldException noSuchFieldException) {
        //field not available. Use method invokation.
        try {
            methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1);
            method = dataClass.getMethod(methodName, null);
        } catch (NoSuchMethodException noSuchMethodException) {
            LOG.error(noSuchMethodException.getMessage(), noSuchMethodException);
            return false;
        }
    }

    for (int index = 0; index < size() - 1; index++) {
        for (int nextIndex = index + 1; nextIndex < size(); nextIndex++) {
            current = get(index);
            next = get(nextIndex);
            //Check if current and next implements Comparable else can't compare.
            //so return without comparing.May be we can have an exception for this purpose.
            try {
                if (field != null && field.isAccessible()) {
                    Comparable thisObj = (Comparable) field.get(current);
                    Comparable otherObj = (Comparable) field.get(next);
                    if (thisObj == null) {
                        compareValue = -1;
                    } else if (otherObj == null) {
                        compareValue = 1;
                    } else {
                        if (thisObj instanceof String && ignoreCase) {
                            compareValue = ((String) thisObj).compareToIgnoreCase((String) otherObj);
                        } else {
                            compareValue = thisObj.compareTo(otherObj);
                        }
                    }
                } else {
                    Comparable thisObj = null;
                    Comparable otherObj = null;
                    if (methodName != null) {
                        Method thisObjMethod = current.getClass().getMethod(methodName, null);
                        Method otherObjMethod = next.getClass().getMethod(methodName, null);
                        thisObj = (Comparable) thisObjMethod.invoke(current, null);
                        otherObj = (Comparable) otherObjMethod.invoke(next, null);
                    } else {
                        thisObj = (Comparable) method.invoke(current, null);
                        otherObj = (Comparable) method.invoke(next, null);
                    }
                    if (thisObj == null) {
                        compareValue = -1;
                    } else if (otherObj == null) {
                        compareValue = 1;
                    } else {
                        if (thisObj instanceof String && ignoreCase) {
                            compareValue = ((String) thisObj).compareToIgnoreCase((String) otherObj);
                        } else {
                            compareValue = thisObj.compareTo(otherObj);
                        }
                    }
                }
            } catch (IllegalAccessException illegalAccessException) {
                LOG.warn(illegalAccessException.getMessage());
                return false;
            } catch (InvocationTargetException invocationTargetException) {
                LOG.warn(invocationTargetException.getMessage(), invocationTargetException);
                return false;
            } catch (SecurityException e) {
                LOG.warn(e.getMessage(), e);
                return false;
            } catch (NoSuchMethodException e) {
                LOG.warn(e.getMessage(), e);
                return false;
            }

            if (ascending && compareValue > 0) {
                E temp = get(index);
                set(index, get(nextIndex));
                set(nextIndex, temp);
            } else if (!ascending && compareValue < 0) {
                E temp = get(index);
                set(index, get(nextIndex));
                set(nextIndex, temp);
            }

        }
    }
    return true;
}

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

@Override
protected void okPressed() {
    if (invalidWidgetValue(cboLayer, cboXField, cboYField, cboSize)) {
        openInformation(getShell(), Messages.Task_ParameterRequired);
        return;/*  w  ww  . j a v  a  2 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.locationtech.udig.processingtoolbox.tools.FieldCalculatorDialog.java

@Override
protected void okPressed() {
    if (source == null || cboField.getText().length() == 0 || cboType.getText().length() == 0
            || txtExpression.getText().length() == 0) {
        openInformation(getShell(), Messages.FieldCalculatorDialog_Warning);
        return;/* ww w .  ja v  a2  s  . co  m*/
    }

    try {
        PlatformUI.getWorkbench().getProgressService().run(false, true, this);
        openInformation(getShell(), Messages.General_Completed);
    } 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.unitime.timetable.solver.jgroups.CourseSolverContainerRemote.java

@Override
public Object dispatch(Address address, String user, Method method, Object[] args) throws Exception {
    try {/*w  w w .  j  av a 2s  .co m*/
        return iDispatcher.callRemoteMethod(address, "invoke",
                new Object[] { method.getName(), user, method.getParameterTypes(), args },
                new Class[] { String.class, String.class, Class[].class, Object[].class },
                SolverServerImplementation.sFirstResponse);
    } catch (InvocationTargetException e) {
        if (e.getTargetException() != null && e.getTargetException() instanceof Exception)
            throw (Exception) e.getTargetException();
        else
            throw e;
    } catch (Exception e) {
        if ("exists".equals(method.getName()) && e instanceof SuspectedException)
            return false;
        sLog.error("Excution of " + method.getName() + " on solver " + user + " failed: " + e.getMessage(), e);
        throw e;
    }
}

From source file:org.unitime.timetable.solver.jgroups.OnlineStudentSchedulingContainerRemote.java

@Override
public Object dispatch(Address address, String sessionId, Method method, Object[] args) throws Exception {
    try {/*  w w  w.j a  va 2 s  .c om*/
        return iDispatcher.callRemoteMethod(address, "invoke",
                new Object[] { method.getName(), sessionId, method.getParameterTypes(), args },
                new Class[] { String.class, String.class, Class[].class, Object[].class },
                SolverServerImplementation.sFirstResponse);
    } catch (InvocationTargetException e) {
        if (e.getTargetException() != null && e.getTargetException() instanceof Exception)
            throw (Exception) e.getTargetException();
        else
            throw e;
    } catch (Exception e) {
        if ("exists".equals(method.getName()) && e instanceof SuspectedException)
            return false;
        sLog.debug("Excution of " + method.getName() + " on server " + sessionId + " failed: " + e.getMessage(),
                e);
        throw e;
    }
}

From source file:org.kuali.kra.budget.calculator.QueryList.java

/**
 * sorts the QueryList by the fieldName in ascending or descending order.
 * Note: the field Object should be of Comparable type.
 * @return boolean indicating whether the sort is completed successfully or not.
 * @param ignoreCase use only when comparing strings. as default implementation uses case sensitive comparison.
 * @param fieldName field which is used to sort the bean.
 * @param ascending if true sorting is done in ascending order,
 * else sorting is done in descending order.
 *//*from w ww. ja  v  a  2s  . c o  m*/
@SuppressWarnings("rawtypes")
public boolean sort(String fieldName, boolean ascending, boolean ignoreCase) {
    Object current, next;
    int compareValue = 0;
    Field field = null;
    Method method = null;
    if (this.size() == 0) {
        return false;
    }
    Class dataClass = get(0).getClass();
    String methodName = null;
    try {
        field = dataClass.getDeclaredField(fieldName);
        if (!field.isAccessible()) {
            throw new NoSuchFieldException();
        }
    } catch (NoSuchFieldException noSuchFieldException) {
        //field not available. Use method invokation.
        try {
            methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1);
            method = dataClass.getMethod(methodName, null);
        } catch (NoSuchMethodException noSuchMethodException) {
            noSuchMethodException.printStackTrace();
            return false;
        }
    }

    for (int index = 0; index < size() - 1; index++) {
        for (int nextIndex = index + 1; nextIndex < size(); nextIndex++) {
            current = get(index);
            next = get(nextIndex);
            //Check if current and next implements Comparable else can't compare.
            //so return without comparing.May be we can have an exception for this purpose.
            try {
                if (field != null && field.isAccessible()) {
                    Comparable thisObj = (Comparable) field.get(current);
                    Comparable otherObj = (Comparable) field.get(next);
                    if (thisObj == null) {
                        compareValue = -1;
                    } else if (otherObj == null) {
                        compareValue = 1;
                    } else {
                        if (thisObj instanceof String && ignoreCase) {
                            compareValue = ((String) thisObj).compareToIgnoreCase((String) otherObj);
                        } else {
                            compareValue = thisObj.compareTo(otherObj);
                        }
                    }
                } else {
                    Comparable thisObj = null;
                    Comparable otherObj = null;
                    if (methodName != null) {
                        Method thisObjMethod = current.getClass().getMethod(methodName, null);
                        Method otherObjMethod = next.getClass().getMethod(methodName, null);
                        thisObj = (Comparable) thisObjMethod.invoke(current, null);
                        otherObj = (Comparable) otherObjMethod.invoke(next, null);
                    } else {
                        thisObj = (Comparable) method.invoke(current, null);
                        otherObj = (Comparable) method.invoke(next, null);
                    }
                    if (thisObj == null) {
                        compareValue = -1;
                    } else if (otherObj == null) {
                        compareValue = 1;
                    } else {
                        if (thisObj instanceof String && ignoreCase) {
                            compareValue = ((String) thisObj).compareToIgnoreCase((String) otherObj);
                        } else {
                            compareValue = thisObj.compareTo(otherObj);
                        }
                    }
                }
            } catch (IllegalAccessException illegalAccessException) {
                LOG.warn(illegalAccessException.getMessage());
                return false;
            } catch (InvocationTargetException invocationTargetException) {
                LOG.warn(invocationTargetException.getMessage(), invocationTargetException);
                return false;
            } catch (SecurityException e) {
                LOG.warn(e.getMessage(), e);
                return false;
            } catch (NoSuchMethodException e) {
                LOG.warn(e.getMessage(), e);
                return false;
            }

            if (ascending && compareValue > 0) {
                E temp = get(index);
                set(index, get(nextIndex));
                set(nextIndex, temp);
            } else if (!ascending && compareValue < 0) {
                E temp = get(index);
                set(index, get(nextIndex));
                set(nextIndex, temp);
            }

        }
    }
    return true;
}

From source file:com.architexa.diagrams.relo.parts.ArtifactEditPart.java

public Action getRelAction(final String text, final DirectedRel rel, final Predicate filter) {
    return new Action(text) {
        @Override/*from   ww  w  . j  a va  2s . c  o m*/
        public void run() {
            final CompoundCommand actionCmd = new CompoundCommand();

            final IRunnableWithProgress op = new IRunnableWithProgress() {
                public void run(final IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(text, IProgressMonitor.UNKNOWN);
                    Display.getDefault().asyncExec(new Runnable() {
                        public void run() {
                            ArtifactEditPart.this.showAllDirectRelation(actionCmd, rel, filter);
                            if (actionCmd.size() > 0)
                                ArtifactEditPart.this.execute(actionCmd);
                        }
                    });
                }
            };
            try {
                new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell())
                        .run(true, false, op);
            } catch (InvocationTargetException e) {
                logger.error(e.getMessage());
            } catch (InterruptedException e) {
                logger.error(e.getMessage());
            }
        }
    };
}

From source file:org.apache.sling.ide.eclipse.ui.internal.InstallEditorSection.java

private void initialize() {

    final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration();

    quickLocalInstallButton.setSelection(config.bundleInstallLocally());
    bundleLocalInstallButton.setSelection(!config.bundleInstallLocally());

    SelectionListener listener = new SelectionAdapter() {

        @Override/*from  ww  w .  j  a v  a2 s  . com*/
        public void widgetSelected(SelectionEvent e) {
            execute(new SetBundleInstallLocallyCommand(server, quickLocalInstallButton.getSelection()));
        }
    };

    quickLocalInstallButton.addSelectionListener(listener);
    bundleLocalInstallButton.addSelectionListener(listener);

    Version serverVersion = launchpadServer
            .getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
    final EmbeddedArtifact supportBundle = artifactLocator.loadToolingSupportBundle();

    final Version embeddedVersion = new Version(supportBundle.getVersion());

    updateActionArea(serverVersion, embeddedVersion);

    installOrUpdateSupportBundleLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {

            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            dialog.setCancelable(true);
            try {
                dialog.run(true, false, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        final Version remoteVersion;
                        monitor.beginTask("Installing support bundle", 3);
                        // double-check, just in case
                        monitor.setTaskName("Getting remote bundle version");

                        Version deployedVersion;
                        final String message;
                        try {
                            RepositoryInfo repositoryInfo = ServerUtil.getRepositoryInfo(server.getOriginal(),
                                    monitor);
                            OsgiClient client = osgiClientFactory.createOsgiClient(repositoryInfo);
                            remoteVersion = client
                                    .getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
                            deployedVersion = remoteVersion;

                            monitor.worked(1);

                            if (remoteVersion != null && remoteVersion.compareTo(embeddedVersion) >= 0) {
                                // version already up-to-date, due to bundle version
                                // changing between startup check and now
                                message = "Bundle is already installed and up to date";
                            } else {
                                monitor.setTaskName("Installing bundle");
                                InputStream contents = null;
                                try {
                                    contents = supportBundle.openInputStream();
                                    client.installBundle(contents, supportBundle.getName());
                                } finally {
                                    IOUtils.closeQuietly(contents);
                                }
                                deployedVersion = embeddedVersion;
                                message = "Bundle version " + embeddedVersion + " installed";

                            }
                            monitor.worked(1);

                            monitor.setTaskName("Updating server configuration");
                            final Version finalDeployedVersion = deployedVersion;
                            Display.getDefault().syncExec(new Runnable() {
                                @Override
                                public void run() {
                                    execute(new SetBundleVersionCommand(server,
                                            EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME,
                                            finalDeployedVersion.toString()));
                                    try {
                                        server.save(false, new NullProgressMonitor());
                                    } catch (CoreException e) {
                                        Activator.getDefault().getLog().log(e.getStatus());
                                    }
                                }
                            });
                            monitor.worked(1);

                        } catch (OsgiClientException e) {
                            throw new InvocationTargetException(e);
                        } catch (URISyntaxException e) {
                            throw new InvocationTargetException(e);
                        } catch (IOException e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }

                        Display.getDefault().asyncExec(new Runnable() {
                            @Override
                            public void run() {
                                MessageDialog.openInformation(getShell(), "Support bundle install operation",
                                        message);
                            }
                        });
                    }
                });
            } catch (InvocationTargetException e1) {

                IStatus status = new Status(Status.ERROR, Activator.PLUGIN_ID,
                        "Error while installing support bundle: " + e1.getTargetException().getMessage(),
                        e1.getTargetException());

                ErrorDialog.openError(getShell(), "Error while installing support bundle", e1.getMessage(),
                        status);
            } catch (InterruptedException e1) {
                Thread.currentThread().interrupt();
                return;
            }
        }
    });
}