From 946292048c3c76c0fbc0d0f54fd52598bce6e305 Mon Sep 17 00:00:00 2001 From: nash Date: Sun, 13 Sep 2009 22:01:04 +0000 Subject: Copy r797997, r798040 and r798050 changes from 1.5.1 branch to 1.x branch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814393 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/CompositeConfigurationServiceImpl.java | 68 ++++++++++++++++++---- 1 file changed, 56 insertions(+), 12 deletions(-) (limited to 'branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java') diff --git a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java index 27eb80b3ad..5de0002086 100644 --- a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java +++ b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java @@ -87,6 +87,9 @@ import org.apache.tuscany.sca.implementation.node.builder.impl.NodeCompositeBuil import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.monitor.MonitorRuntimeException; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.IntentAttachPointType; import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; @@ -275,8 +278,13 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se try { String dependencyLocation = dependencyItem.getAlternate(); dependency = contribution(workspace, dependencyURI, dependencyLocation); - } catch (ContributionReadException e) { - continue; + } catch (Exception e) { + if (contributionURI.equals(dependencyURI)) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getDescription(e)); + return; + } else { + continue; + } } workspace.getContributions().add(dependency); contributionMap.put(dependencyURI, dependency); @@ -313,9 +321,10 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se // Fuse includes into the deployable composite try { compositeIncludeBuilder.build(deployable); - } catch (CompositeBuilderException e) { - e.printStackTrace(); //[nash] - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); + analyzeProblems(); + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getDescription(e)); + return; } // Store away the requested composite @@ -387,9 +396,9 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se contractMapper, aggregatedDefinitions, monitor); try { compositeBuilder.build(domainComposite); - } catch (CompositeBuilderException e) { - e.printStackTrace(); //[nash] - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); + analyzeProblems(); + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getDescription(e)); return; } @@ -455,9 +464,7 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se QName formatName = new QName(format.substring(0, s), format.substring(s +1)); processor = (StAXArtifactProcessor)staxProcessors.getProcessor(formatName); if (processor == null) { - Exception e = new IllegalArgumentException(queryString); //[nash] - e.printStackTrace(); //[nash] - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); //[nash] + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, new IllegalArgumentException(queryString).toString()); return; } } else { @@ -468,7 +475,6 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se XMLStreamWriter writer = outputFactory.createXMLStreamWriter(response.getOutputStream()); processor.write(requestedComposite, writer); } catch (Exception e) { - e.printStackTrace(); //[nash] response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); return; } @@ -541,12 +547,27 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se try { URI uri = URI.create(contributionURI); URL location = locationURL(contributionLocation); + Contribution contribution = (Contribution)contributionProcessor.read(null, uri, location); + try { + analyzeProblems(); + } catch (ServiceRuntimeException e) { + throw e; + } catch (Exception e) { + throw new ContributionReadException(e); + } // Resolve the contribution dependencies contributionDependencyBuilder.buildContributionDependencies(contribution, workspace); contributionProcessor.resolve(contribution, workspace.getModelResolver()); + try { + analyzeProblems(); + } catch (ServiceRuntimeException e) { + throw e; + } catch (Exception e) { + throw new ContributionReadException(e); + } return contribution; } catch (ContributionReadException e) { @@ -558,6 +579,29 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se } } + private void analyzeProblems() throws Exception { + + for (Problem problem : monitor.getProblems()) { + if ((problem.getSeverity() == Severity.ERROR) && (!problem.getMessageId().equals("SchemaError"))) { + if (problem.getCause() != null) { + throw new ServiceRuntimeException(new MonitorRuntimeException(problem.getCause())); + } else { + throw new ServiceRuntimeException(new MonitorRuntimeException(problem.toString())); + } + } + } + } + + private String getDescription(Exception e) { + if (e instanceof ServiceRuntimeException && e.getCause() instanceof MonitorRuntimeException) { + Throwable ce = e.getCause(); + return ce.getCause() != null ? ce.getCause().toString() : ce.getMessage(); + } else { + return e.toString(); + } + } + + /** * The following code was copied from RuntimeBootStrapper to fix TUSCANY-3171 * -- cgit v1.2.3