}
if (target.getTarget().getType() == TargetType.DOMAIN && isDeleting) {
// If the target is the domain and the object is being deleted, then we must
// ensure that the there are no references to it.
if (ApplicationHelper.isApplicationReferenced(getConfigContext(), appName)) {
throw new IASDeploymentException(localStrings.getString("applicationIsReferenced",
appName, ApplicationHelper.getApplicationReferenceesAsString(
getConfigContext(), appName)));
}
}
else if (target.getTarget().getType() == TargetType.SERVER ||
target.getTarget().getType() == TargetType.DAS) {
// If the application exists, we must ensure that if a standalone server instance is
// the target, that it must be the only entity referring to the application and
// indeed it must have a reference to the application
if (!ServerHelper.serverReferencesApplication(getConfigContext(),
targetName, appName) && isDeleting) {
throw new IASDeploymentException(localStrings.getString("serverApplicationRefDoesNotExist",
targetName, appName));
} else if (!ApplicationHelper.isApplicationReferencedByServerOnly(getConfigContext(),
appName, targetName)) {
throw new IASDeploymentException(localStrings.getString("applicationHasMultipleRefs",
targetName, appName, ApplicationHelper.getApplicationReferenceesAsString(
getConfigContext(), appName)));
}
} else if (target.getTarget().getType() == TargetType.CLUSTER) {
// If the application exists, we must ensure that if a cluster is
// the target, that it must be the only entity referring to the application and
// indeed it must have a reference to the application
if (!ClusterHelper.clusterReferencesApplication(getConfigContext(),
targetName, appName) && isDeleting) {
throw new IASDeploymentException(localStrings.getString("clusterApplicationRefDoesNotExist",
targetName, appName));
} else if (!ApplicationHelper.isApplicationReferencedByClusterOnly(getConfigContext(),
appName, targetName)) {
throw new IASDeploymentException(localStrings.getString("applicationHasMultipleRefs",
targetName, appName, ApplicationHelper.getApplicationReferenceesAsString(
getConfigContext(), appName)));
}
}
}
return target;
} catch (IASDeploymentException ex) {
throw (ex);
} catch (Exception ex) {
throw new IASDeploymentException(ex);
}
}