Search in sources :

Example 1 with ErrorMessage

use of org.eclipse.wst.server.discovery.ErrorMessage in project webtools.servertools by eclipse.

the class NewRuntimeComposite method refreshExtension.

public boolean refreshExtension() {
    if (!(serverType instanceof ServerTypeProxy))
        return true;
    final ServerTypeProxy finalServerType = (ServerTypeProxy) serverType;
    try {
        wizard.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                ErrorMessage errorMsg = Discovery.refreshExtension(finalServerType.getExtension(), finalServerType.getURI(), monitor);
                if (errorMsg != null) {
                    final ErrorMessage errorMsgFinal = errorMsg;
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            wizard.setMessage(errorMsgFinal.getErrorTitle(), IMessageProvider.ERROR);
                            WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getRuntimeType().getId());
                            if (fragment2 != null) {
                                TaskModel fragmentTaskModel = fragment2.getTaskModel();
                                fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE, errorMsgFinal.getErrorDescription());
                                fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.ERROR));
                            }
                            wizard.update();
                        }
                    });
                } else {
                    WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getRuntimeType().getId());
                    if (fragment2 != null) {
                        TaskModel fragmentTaskModel = fragment2.getTaskModel();
                        fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE, Discovery.getLicenseText(finalServerType.getExtension()));
                        fragmentTaskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.NONE));
                    }
                }
            }
        });
    } catch (InvocationTargetException e) {
        if (Trace.WARNING) {
            Trace.trace(Trace.STRING_WARNING, "Error refreshing extension", e);
        }
    } catch (InterruptedException e) {
        if (Trace.WARNING) {
            Trace.trace(Trace.STRING_WARNING, "Error refreshing extension", e);
        }
    }
    return true;
}
Also used : WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ErrorMessage(org.eclipse.wst.server.discovery.ErrorMessage) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with ErrorMessage

use of org.eclipse.wst.server.discovery.ErrorMessage in project webtools.servertools by eclipse.

the class ExtensionUtility method refreshExtension.

public static ErrorMessage refreshExtension(final String extensionId, String uri, IProgressMonitor monitor) {
    ErrorMessage errorMessageObj = null;
    if (extensionMap.get(extensionId) != null) {
        if (extensionMapError.get(extensionId) == null)
            return null;
    }
    ExtensionUpdateSite site = new ExtensionUpdateSite(uri, null, null);
    try {
        monitor = ProgressUtil.getMonitorFor(monitor);
        monitor.beginTask("", 1000);
        monitor.subTask(Messages.fetchingRepository);
        IProgressMonitor subMonitor = ProgressUtil.getSubMonitorFor(monitor, 500);
        List<IServerExtension> list = site.getExtensions(subMonitor);
        monitor.worked(500);
        if (monitor.isCanceled())
            return null;
        boolean firstIteration = true;
        for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
            IServerExtension iServerExtension = (IServerExtension) iterator.next();
            if (iServerExtension.getId().equals(extensionId)) {
                Extension extension = (Extension) iServerExtension;
                if (extensionMap.get(extensionId) != null && !firstIteration && extension.getVersion().compareTo(((Extension) extensionMap.get(extensionId)).getVersion()) <= 0)
                    continue;
                subMonitor = ProgressUtil.getSubMonitorFor(monitor, 500);
                monitor.subTask(Messages.validateInstall);
                final IProvisioningPlan plan = extension.getProvisioningPlan(true, subMonitor);
                if (monitor.isCanceled())
                    return null;
                if (plan == null || !plan.getStatus().isOK()) {
                    if (plan != null) {
                        StringBuffer detailedErrorMsg = new StringBuffer();
                        IStatus[] statusList = plan.getStatus().getChildren();
                        for (int i = 0; i < statusList.length; i++) {
                            detailedErrorMsg.append(statusList[i].getMessage());
                        }
                        errorMessageObj = new ErrorMessage(Messages.validateInstallError, detailedErrorMsg.toString());
                        Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, detailedErrorMsg.toString(), plan.getStatus().getException()));
                    } else {
                        errorMessageObj = new ErrorMessage(Messages.validateInstallError, Messages.fetchingRepositoryFailure);
                        Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Could not get the provisioning plan", null));
                    }
                }
                extensionMap.put(extensionId, extension);
                extensionMapError.put(extensionId, errorMessageObj);
                firstIteration = false;
            }
        }
        return errorMessageObj;
    } catch (CoreException e) {
        Trace.trace(Trace.SEVERE, "Could not refresh server adapter node.");
        return new ErrorMessage(Messages.fetchingRepositoryFailure, e.getLocalizedMessage());
    }
}
Also used : IProvisioningPlan(org.eclipse.equinox.p2.engine.IProvisioningPlan) ErrorMessage(org.eclipse.wst.server.discovery.ErrorMessage)

Example 3 with ErrorMessage

use of org.eclipse.wst.server.discovery.ErrorMessage in project webtools.servertools by eclipse.

the class NewManualServerComposite method refreshExtension.

public boolean refreshExtension() {
    if (!(oldServerType instanceof ServerTypeProxy))
        return true;
    final ServerTypeProxy finalServerType = (ServerTypeProxy) oldServerType;
    try {
        wizard.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                ErrorMessage errorMsg = Discovery.refreshExtension(finalServerType.getExtension(), finalServerType.getURI(), monitor);
                if (errorMsg != null) {
                    final ErrorMessage errorMsgFinal = errorMsg;
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            canProceed = false;
                            wizard.setMessage(errorMsgFinal.getErrorTitle(), IMessageProvider.ERROR);
                            WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getId());
                            if (fragment2 != null) {
                                TaskModel taskModel = fragment2.getTaskModel();
                                taskModel.putObject(LicenseWizardFragment.LICENSE, errorMsgFinal.getErrorDescription());
                                taskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.ERROR));
                            }
                            wizard.update();
                        }
                    });
                } else {
                    WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(finalServerType.getId());
                    if (fragment2 != null) {
                        TaskModel taskModel = fragment2.getTaskModel();
                        taskModel.putObject(LicenseWizardFragment.LICENSE, Discovery.getLicenseText(finalServerType.getExtension()));
                        taskModel.putObject(LicenseWizardFragment.LICENSE_ERROR, new Integer(IMessageProvider.NONE));
                    }
                }
            }
        });
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return true;
}
Also used : LicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ErrorMessage(org.eclipse.wst.server.discovery.ErrorMessage) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

ErrorMessage (org.eclipse.wst.server.discovery.ErrorMessage)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 LicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment)2 WizardFragment (org.eclipse.wst.server.ui.wizard.WizardFragment)2 IProvisioningPlan (org.eclipse.equinox.p2.engine.IProvisioningPlan)1