private DeploymentTarget getAndValidateDeploymentTarget(String targetName,
String appName, boolean isRegistered, boolean isDeleting) throws IASDeploymentException
{
try {
final DeploymentTarget target = getTargetFactory().getTarget(
getConfigContext(), getDomainName(), targetName);
if (isRegistered) {
if (targetName == null) {
//If the targetName passed in was null, we need to set it to its default value.
targetName = target.getTarget().getName();
}
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) {