// for each matched version
Iterator it = matchedVersions.iterator();
while (it.hasNext()) {
String appName = (String) it.next();
Application app = applications.getApplication(appName);
ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target);
if ( applicationRef != null ) {
// we provides warning messages
// if a versioned name has been provided to the command
if( isVersionExpression ){
ActionReport.MessagePart childPart = part.addChild();
childPart.setMessage(localStrings.getLocalString("appref.already.exists",
"Application reference {0} already exists in target {1}.", appName, target));
} else {
// returns failure if an untagged name has been provided to the command
report.setMessage(localStrings.getLocalString("appref.already.exists",
"Application reference {0} already exists in target {1}.", name, target));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
} else {
Transaction t = new Transaction();
if (app.isLifecycleModule()) {
handleLifecycleModule(context, t);
return;
}
ReadableArchive archive;
File file = null;
DeployCommandParameters commandParams=null;
Properties contextProps = new Properties();
Map<String, Properties> modulePropsMap = null;
ApplicationConfigInfo savedAppConfig = null;
try {
commandParams = app.getDeployParameters(null);
commandParams.origin = Origin.create_application_ref;
commandParams.target = target;
commandParams.virtualservers = virtualservers;
commandParams.enabled = enabled;
if(lbenabled != null){
commandParams.lbenabled = lbenabled;
}
if (app.containsSnifferType(Application.OSGI_SNIFFER_TYPE)) {
commandParams.type = DeploymentProperties.OSGI;
}
contextProps = app.getDeployProperties();
modulePropsMap = app.getModulePropertiesMap();
savedAppConfig = new ApplicationConfigInfo(app);
URI uri = new URI(app.getLocation());
file = new File(uri);
if (!file.exists()) {
report.setMessage(localStrings.getLocalString("fnf",
"File not found", file.getAbsolutePath()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
archive = archiveFactory.openArchive(file);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error opening deployable artifact : " + file.getAbsolutePath(), e);
report.setMessage(localStrings.getLocalString("unknownarchiveformat", "Archive format not recognized"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
final ExtendedDeploymentContext deploymentContext =
deployment.getBuilder(logger, commandParams, report).source(archive).build();
Properties appProps = deploymentContext.getAppProps();
appProps.putAll(contextProps);
// relativize the location so it could be set properly in
// domain.xml
String location = DeploymentUtils.relativizeWithinDomainIfPossible(new URI(app.getLocation()));
appProps.setProperty(ServerTags.LOCATION, location);
// relativize the URI properties so they could store in the
// domain.xml properly on the instances
String appLocation = appProps.getProperty(Application.APP_LOCATION_PROP_NAME);