1 22 package org.jboss.deployers.spi; 23 24 import java.util.Collection ; 25 import java.util.HashMap ; 26 import java.util.Map ; 27 import java.util.Set ; 28 29 35 public class IncompleteDeploymentException extends DeploymentException 36 { 37 38 private static final long serialVersionUID = 1433292979582684692L; 39 40 41 private IncompleteDeployments incompleteDeployments; 42 43 46 public IncompleteDeploymentException() 47 { 48 } 49 50 56 public IncompleteDeploymentException(IncompleteDeployments incompleteDeployments) 57 { 58 if (incompleteDeployments == null) 59 throw new IllegalArgumentException ("Null incompleteDeployments"); 60 this.incompleteDeployments = incompleteDeployments; 61 } 62 63 68 public IncompleteDeployments getIncompleteDeployments() 69 { 70 return incompleteDeployments; 71 } 72 73 @Override 75 public String getMessage() 76 { 77 StringBuilder buffer = new StringBuilder (); 78 buffer.append("Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):\n"); 79 80 Collection <String > deploymentsMissingDeployers = incompleteDeployments.getDeploymentsMissingDeployer(); 82 if (deploymentsMissingDeployers.isEmpty() == false) 83 { 84 buffer.append("\n*** DEPLOYMENTS MISSING DEPLOYERS: Name\n\n"); 85 for (String name : deploymentsMissingDeployers) 86 buffer.append(name).append('\n'); 87 } 88 89 Map <String , Throwable > deploymentsInError = incompleteDeployments.getDeploymentsInError(); 91 if (deploymentsInError.isEmpty() == false) 92 { 93 buffer.append("\n*** DEPLOYMENTS IN ERROR: Name -> Error\n\n"); 94 for (Map.Entry <String , Throwable > entry : deploymentsInError.entrySet()) 95 buffer.append(entry.getKey()).append(" -> ").append(entry.getValue().toString()).append("\n\n"); 96 } 97 98 Map <String , String > rootCauses = new HashMap <String , String >(); 100 101 Map <String , Set <MissingDependency>> contextsMissingDependencies = incompleteDeployments.getContextsMissingDependencies(); 103 if (contextsMissingDependencies.isEmpty() == false) 104 { 105 for (Map.Entry <String , Set <MissingDependency>> entry : contextsMissingDependencies.entrySet()) 106 { 107 for (MissingDependency dependency : entry.getValue()) 108 rootCauses.put(dependency.getDependency(), dependency.getActualState()); 109 } 110 } 111 112 Map <String , Throwable > contextsInError = incompleteDeployments.getContextsInError(); 114 if (contextsInError.isEmpty() == false) 115 { 116 for (Map.Entry <String , Throwable > entry : contextsInError.entrySet()) 117 { 118 Throwable t = entry.getValue(); 119 if (t == null) 120 rootCauses.put(entry.getKey(), "** UNKNOWN ERROR **"); 121 else 122 rootCauses.put(entry.getKey(), t.toString()); 123 } 124 } 125 126 if (contextsMissingDependencies.isEmpty() == false) 128 { 129 buffer.append("\n*** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n\n"); 130 for (Map.Entry <String , Set <MissingDependency>> entry : contextsMissingDependencies.entrySet()) 131 { 132 String name = entry.getKey(); 133 buffer.append(name).append("\n"); 134 for (MissingDependency dependency : entry.getValue()) 135 { 136 buffer.append(" -> ").append(dependency.getDependency()); 137 buffer.append('{').append(dependency.getRequiredState()); 138 buffer.append(':').append(dependency.getActualState()).append("}"); 139 buffer.append("\n"); 140 } 141 buffer.append('\n'); 142 143 rootCauses.remove(name); 145 } 146 } 147 if (rootCauses.isEmpty() == false) 148 { 149 buffer.append("\n*** CONTEXTS IN ERROR: Name -> Error\n\n"); 150 for (Map.Entry <String , String > entry : rootCauses.entrySet()) 151 buffer.append(entry.getKey()).append(" -> ").append(entry.getValue()).append("\n\n"); 152 } 153 return buffer.toString(); 154 } 155 } 156 | Popular Tags |