use of org.eclipse.core.runtime.MultiStatus in project webtools.servertools by eclipse.
the class TomcatVersionHelper method addCatalinaContextConfig.
/**
* If the specified Context is linked to a project, try to
* update it with any configuration from a META-INF/context.xml found
* relative to the specified web applications directory and context docBase.
*
* @param webappsDir Path to server's web applications directory.
* @param context Context object to receive context.xml contents.
* @param ms MultiStatus object to receive error status.
* @return Returns true if context is modified.
*/
private static boolean addCatalinaContextConfig(IPath webappsDir, Context context, MultiStatus ms) {
boolean modified = false;
String source = context.getSource();
if (source != null && source.length() > 0) {
File docBase = new File(context.getDocBase());
if (!docBase.isAbsolute())
docBase = new File(webappsDir.toOSString(), docBase.getPath());
try {
Context contextConfig = loadCatalinaContextConfig(docBase);
if (null != contextConfig) {
if (context.hasChildNodes())
context.removeChildren();
contextConfig.copyChildrenTo(context);
Map attrs = contextConfig.getAttributes();
Iterator iter = attrs.keySet().iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
if (!name.equalsIgnoreCase("path") && !name.equalsIgnoreCase("docBase") && !name.equalsIgnoreCase("source")) {
String value = (String) attrs.get(name);
context.setAttributeValue(name, value);
}
}
modified = true;
}
} catch (Exception e) {
String contextPath = context.getPath();
if (contextPath.startsWith("/")) {
contextPath = contextPath.substring(1);
}
Trace.trace(Trace.SEVERE, "Error reading context.xml file for " + contextPath, e);
IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadContextXml, contextPath), e);
ms.add(s);
}
}
return modified;
}
use of org.eclipse.core.runtime.MultiStatus in project epp.mpc by eclipse.
the class TransportFactory method diagnoseTransportServiceRegistration.
private static IStatus diagnoseTransportServiceRegistration(BundleContext context, ServiceReference<ITransportFactory> serviceReference) {
MultiStatus serviceError = null;
if (serviceReference != null) {
serviceError = new MultiStatus(MarketplaceClientCore.BUNDLE_ID, 0, Messages.TransportFactory_ServiceErrorUnregistered, null);
serviceError.add(new Status(IStatus.ERROR, MarketplaceClientCore.BUNDLE_ID, Messages.TransportFactory_ServiceErrorServiceReference + serviceReference));
} else {
serviceError = new MultiStatus(MarketplaceClientCore.BUNDLE_ID, 0, Messages.TransportFactory_ServiceErrorNotFound, null);
try {
Collection<ServiceReference<ITransportFactory>> allServiceReferences = context.getServiceReferences(ITransportFactory.class, null);
if (allServiceReferences.isEmpty()) {
serviceError.add(new Status(IStatus.ERROR, MarketplaceClientCore.BUNDLE_ID, Messages.TransportFactory_ServiceErrorNoneAvailable));
} else {
String filter = computeDisabledTransportsFilter();
serviceError.add(new Status(IStatus.ERROR, MarketplaceClientCore.BUNDLE_ID, Messages.TransportFactory_ServiceErrorAppliedFilter + filter));
}
for (ServiceReference<ITransportFactory> availableReference : allServiceReferences) {
serviceError.add(new Status(IStatus.INFO, MarketplaceClientCore.BUNDLE_ID, Messages.TransportFactory_ServiceErrorFilteredService + availableReference.toString()));
}
} catch (InvalidSyntaxException e) {
// Unreachable
serviceError.add(new Status(IStatus.ERROR, MarketplaceClientCore.BUNDLE_ID, Messages.TransportFactory_ServiceErrorDetails, e));
}
}
return serviceError;
}
use of org.eclipse.core.runtime.MultiStatus in project epp.mpc by eclipse.
the class MarketplaceCatalog method performNewsDiscovery.
public IStatus performNewsDiscovery(IProgressMonitor monitor) {
if (getDiscoveryStrategies().isEmpty()) {
throw new IllegalStateException();
}
INews news = null;
MultiStatus status = new MultiStatus(MarketplaceClientUi.BUNDLE_ID, 0, Messages.MarketplaceCatalog_queryFailed, null);
final int totalTicks = 100000;
final SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceCatalog_Checking_News, totalTicks);
try {
int strategyTicks = totalTicks / getDiscoveryStrategies().size();
for (AbstractDiscoveryStrategy discoveryStrategy : getDiscoveryStrategies()) {
if (monitor.isCanceled()) {
status.add(Status.CANCEL_STATUS);
break;
}
if (discoveryStrategy instanceof MarketplaceDiscoveryStrategy) {
try {
MarketplaceDiscoveryStrategy marketplaceStrategy = (MarketplaceDiscoveryStrategy) discoveryStrategy;
news = marketplaceStrategy.performNewsDiscovery(progress.newChild(strategyTicks));
if (news != null) {
break;
}
} catch (CoreException e) {
status.add(new Status(e.getStatus().getSeverity(), DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.MarketplaceCatalog_failedWithError, discoveryStrategy.getClass().getSimpleName()), e));
}
}
}
} finally {
monitor.done();
}
if (status.isOK()) {
setNews(news);
}
return status;
}
use of org.eclipse.core.runtime.MultiStatus in project epp.mpc by eclipse.
the class MarketplaceCatalog method performDiscovery.
@Override
public IStatus performDiscovery(IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, 200000);
IStatus status = super.performDiscovery(progress.newChild(100000));
// check for updates
if (status.getSeverity() < IStatus.ERROR) {
IStatus updateStatus = checkForUpdates(progress.newChild(100000));
if (!updateStatus.isOK()) {
if (status.isOK()) {
status = updateStatus;
} else {
MultiStatus multiStatus = new MultiStatus(MarketplaceClientUi.BUNDLE_ID, 0, Messages.MarketplaceCatalog_Discovery_Error, null);
multiStatus.add(status);
multiStatus.add(updateStatus);
status = multiStatus;
}
}
}
return computeStatus(status);
}
use of org.eclipse.core.runtime.MultiStatus in project vsDiaryWriter by shilongdai.
the class ExceptionDisplayer method errorDialogWithStackTrace.
public static void errorDialogWithStackTrace(String msg, Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
// stack trace as a string
final String trace = sw.toString();
// Temp holder of child statuses
List<Status> childStatuses = new ArrayList<>();
// Split output by OS-independend new-line
for (String line : trace.split(System.getProperty("line.separator"))) {
// build & add status
childStatuses.add(new Status(IStatus.ERROR, "Journal", line));
}
MultiStatus ms = new // convert
MultiStatus(// convert
"Journal", // convert
IStatus.ERROR, // convert
childStatuses.toArray(new Status[] {}), // statuses
t.getLocalizedMessage(), t);
ErrorDialog.openError(null, "Error", msg, ms);
}
Aggregations