Skip to content

Commit

Permalink
Fixes creation of a Glassfish deployment descriptor (#3219)
Browse files Browse the repository at this point in the history
  • Loading branch information
jGauravGupta committed Jan 13, 2022
1 parent 84bd3ea commit de94f12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
Expand Up @@ -30,6 +30,8 @@
import org.netbeans.modules.glassfish.eecommon.api.config.J2eeModuleHelper;
import org.netbeans.modules.j2ee.dd.api.common.RootInterface;
import org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException;
import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar;
import org.netbeans.modules.j2ee.dd.api.web.WebApp;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
import org.openide.filesystems.FileObject;
Expand Down Expand Up @@ -177,30 +179,10 @@ public boolean accept(File f) {
}

public static FileObject getSunDDFromProjectsModuleVersion(J2eeModule mod, String sunDDFileName) {
FileObject retVal = null;
String suffix = "-java_ee_5/";
if (null != mod) {
String modVer = mod.getModuleVersion();
J2eeModule.Type t = mod.getType();
// ejb 2.0, 2.1, 3.0, 3.1
// web 2.3, 2.4, 2.5, 3.0
// appcli 1.3, 1.4, 5.0, 6.0
// ear 1.3, 1.4, 5, 6
if (modVer.equals("6") || modVer.equals("6.0") || modVer.endsWith("1.6") || modVer.equals("3.1")) {
suffix = "-java_ee/";
} else if (modVer.equals("3.0")) {
if (J2eeModule.Type.WAR.equals(t)) {
suffix = "-java_ee/";
}
} else if (modVer.equals("1.4") || modVer.equals("2.4") || modVer.equals("2.1")) {
suffix = "-j2ee_1_4/";
} else if (modVer.equals("2.0") || modVer.equals("2.3") || modVer.equals("1.3")) {
suffix = "-j2ee_1_3/";
}
}
FileObject retVal;
String suffix = "-java_ee/";
String resource = "org-netbeans-modules-glassfish-eecommon-ddtemplates" + suffix + sunDDFileName; // NOI18N
retVal = FileUtil.getConfigFile(resource);

return retVal;
}

Expand Down
Expand Up @@ -41,6 +41,7 @@ public final class SunDDVisualPanel extends JPanel {
private String sunDDFileName;
private File sunDDFile;
private File sunDDLocation;
private static final String STANDARD_DD_NAME = "web.xml";

public SunDDVisualPanel() {
initComponents();
Expand All @@ -58,10 +59,10 @@ void setProject(final Project project) {
J2eeModule j2eeModule = provider.getJ2eeModule();
sunDDFileName = getConfigFileName(j2eeModule,provider.getServerInstanceID());

// Calculate location:
sunDDFile = (sunDDFileName != null) ? j2eeModule.getDeploymentConfigurationFile(sunDDFileName) : null;
sunDDLocation = (sunDDFile != null) ? sunDDFile.getParentFile() : null;
// Calculate location:
sunDDLocation = j2eeModule.getDeploymentConfigurationFile(STANDARD_DD_NAME).getParentFile();
sunDDFile = (sunDDFileName != null) ? new File(sunDDLocation, sunDDFileName) : null;

// initialize visual components
textFileName.setText(sunDDFileName); // NOI18N
textProjectName.setText(ProjectUtils.getInformation(project).getDisplayName());
Expand Down

0 comments on commit de94f12

Please sign in to comment.