public void removeComponent(ManagedComponent comp) throws Exception
{
if(comp == null)
throw new IllegalArgumentException("null managed component.");
//
ManagedDeployment md = comp.getDeployment();
// Get the parent
while( md.getParent() != null )
md = md.getParent();
String name = md.getName();
ProfileDeployment profileDeployment = getProfileDeployment(name);
if( profileDeployment == null )
{
formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
Object[] args = {name};
String msg = formatter.format(args);
throw new NoSuchDeploymentException(msg);
}
// Apply the managed properties to the server ManagedDeployment/ManagedComponent
ManagedDeployment compMD = managedDeployments.get(md.getName());
log.debug("updateComponent, deploymentName="+name+": "+compMD);
ManagedComponent serverComp = null;
// Find the managed component again
if(comp.getDeployment().getParent() == null)
{
serverComp = compMD.getComponent(comp.getName());
}
else
{
// Look at the children
// TODO - support more levels of nested deployments ?
if(compMD.getChildren() != null && compMD.getChildren().isEmpty() == false)
{
for(ManagedDeployment child : compMD.getChildren())
{
if(serverComp != null)
break;
serverComp = child.getComponent(comp.getName());
}
}
}
if(serverComp == null)
{
log.debug("Name: "+comp.getName()+" does not map to existing ManagedComponet in ManagedDeployment: "+md.getName()
+ ", components: "+compMD.getComponents());
formatter.applyPattern(i18n.getString("ManagementView.InvalidComponentName")); //$NON-NLS-1$
Object[] args = {comp.getName(), md.getName()};
String msg = formatter.format(args);
throw new IllegalArgumentException(msg);
}