{
try
{
try
{
ManagedDeployment md = getManagedDeployment(deployment);
processRootManagedDeployment(md, key, trace);
// TODO update profileservice-spi
// Cache the deployment types
if(md.getTypes() != null && md.getTypes().isEmpty() == false)
((AbstractProfileDeployment)deployment)
.addTransientAttachment(KnownDeploymentTypes.class.getName(), md.getTypes());
}
catch(DeploymentException e)
{
// FIXME Assume a undeployed (stopped) deployment
String deploymentName = deployment.getName();
ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
deployment.getRoot().getName());
// TODO update profileservice-spi
// Try to get the cached deployment type
Collection<String> deploymentTypes = (Collection<String>) ((AbstractProfileDeployment)deployment)
.getTransientAttachment(KnownDeploymentTypes.class.getName());
if(deploymentTypes != null)
{
md.setTypes(new HashSet<String>(deploymentTypes));
}
else
{
int i = deploymentName.lastIndexOf(".");
if(i != -1 && (i + 1) < deploymentName.length())
{
String guessedType = deploymentName.substring(i + 1, deploymentName.length());
if(guessedType.endsWith("/"))
guessedType = guessedType.substring(0, guessedType.length() -1 );
md.setTypes(new HashSet<String>(1));
md.addType(guessedType);
}
}
processManagedDeployment(md, key, DeploymentState.STOPPED, 0, trace);
}