Skip to content

Commit

Permalink
Merge pull request #7036 from luiseufrasio/FISH-8103-asadmin-undeploy…
Browse files Browse the repository at this point in the history
…-command-not-working-p6

FISH-8103 : checking if app already deployed on instance to just crea…
  • Loading branch information
luiseufrasio authored Oct 28, 2024
2 parents 7e06ea6 + 8d47d69 commit ef4ffc2
Showing 1 changed file with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2021] [Payara Foundation]
// Portions Copyright [2016-2024] [Payara Foundation]

package org.glassfish.deployment.admin;

Expand All @@ -48,6 +48,7 @@
import java.util.Calendar;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -218,29 +219,33 @@ public void execute(AdminCommandContext ctxt) {
} else {
t = deployment.prepareAppConfigChanges(deploymentContext);
}

ApplicationInfo appInfo;
appInfo = deployment.deploy(deploymentContext);

if (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS) {
try {
moveAltDDFilesToPermanentLocation(deploymentContext, logger);
// register application information in domain.xml
if (application != null) {
// application element already synchronized over
// just write application-ref
deployment.registerAppInDomainXML(appInfo, deploymentContext, t, true);
} else {
// write both application and application-ref
deployment.registerAppInDomainXML(appInfo, deploymentContext, t);

ApplicationInfo appInfo = getApplicationInfo(deploymentContext);
if (appInfo != null) {
deployment.registerAppInDomainXML(appInfo, deploymentContext, t, true);
} else {
appInfo = deployment.deploy(deploymentContext);

if (report.getActionExitCode() == ActionReport.ExitCode.SUCCESS) {
try {
moveAltDDFilesToPermanentLocation(deploymentContext, logger);
// register application information in domain.xml
if (application != null) {
// application element already synchronized over
// just write application-ref
deployment.registerAppInDomainXML(appInfo, deploymentContext, t, true);
} else {
// write both application and application-ref
deployment.registerAppInDomainXML(appInfo, deploymentContext, t);
}
} catch (Exception e) {
// roll back the deployment and re-throw the exception
deployment.undeploy(name, deploymentContext);
deploymentContext.clean();
throw e;
}
} catch (Exception e) {
// roll back the deployment and re-throw the exception
deployment.undeploy(name, deploymentContext);
deploymentContext.clean();
throw e;
}
}
}
} catch (Throwable e) {
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(e.getMessage());
Expand Down Expand Up @@ -280,9 +285,17 @@ public void execute(AdminCommandContext ctxt) {
// to print the same message again
report.setFailureCause(null);
}

}
}

private ApplicationInfo getApplicationInfo(ExtendedDeploymentContext deploymentContext) {
ApplicationInfo applicationInfo = null;
Properties appProps = deploymentContext.getAppProps();
if (appProps != null) {
String appName = appProps.getProperty("defaultAppName");
applicationInfo = deployment.get(appName);
}
return applicationInfo;
}

private void processGeneratedContent(
Expand Down

0 comments on commit ef4ffc2

Please sign in to comment.