This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 222924
Collapse All | Expand All

(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/InitialServerFileDistributor.java (-23 / +37 lines)
Lines 53-60 Link Here
53
import java.io.InputStream;
53
import java.io.InputStream;
54
import java.io.OutputStream;
54
import java.io.OutputStream;
55
import java.nio.channels.FileChannel;
55
import java.nio.channels.FileChannel;
56
import java.util.HashSet;
56
import java.util.Iterator;
57
import java.util.Iterator;
57
import java.util.Locale;
58
import java.util.Locale;
59
import java.util.Set;
58
import java.util.jar.JarOutputStream;
60
import java.util.jar.JarOutputStream;
59
import java.util.logging.Level;
61
import java.util.logging.Level;
60
import java.util.logging.Logger;
62
import java.util.logging.Logger;
Lines 120-126 Link Here
120
            setStatusDistributeRunning(NbBundle.getMessage(
122
            setStatusDistributeRunning(NbBundle.getMessage(
121
                InitialServerFileDistributor.class, "MSG_RunningInitialDeploy", dtarget.getDeploymentName(), dir));
123
                InitialServerFileDistributor.class, "MSG_RunningInitialDeploy", dtarget.getDeploymentName(), dir));
122
124
123
            _distribute(source.getArchiveContents(), dir);
125
            _distribute(source.getArchiveContents(), dir, collectChildModuleNames(source));
124
126
125
            if (source instanceof J2eeApplication) {
127
            if (source instanceof J2eeApplication) {
126
                J2eeModule[] childModules = ((J2eeApplication) source).getModules();
128
                J2eeModule[] childModules = ((J2eeApplication) source).getModules();
Lines 128-134 Link Here
128
                    String uri = childModules[i].getUrl();
130
                    String uri = childModules[i].getUrl();
129
                    J2eeModule childModule = deployment.getJ2eeModule(uri);
131
                    J2eeModule childModule = deployment.getJ2eeModule(uri);
130
                    File subdir = incDeployment.getDirectoryForNewModule(dir, uri, childModule, deployment.getModuleConfiguration());
132
                    File subdir = incDeployment.getDirectoryForNewModule(dir, uri, childModule, deployment.getModuleConfiguration());
131
                    _distribute(childModules[i].getArchiveContents(), subdir);
133
                    _distribute(childModules[i].getArchiveContents(), subdir, null);
132
                }
134
                }
133
            }
135
            }
134
136
Lines 147-152 Link Here
147
        return null;
149
        return null;
148
    }
150
    }
149
151
152
    // We are collecting module names to be able to skip .jar and .war files under
153
    // the application root with the same name as one of the deployed modules. Those
154
    // are typically jars coresponding to already existing exploded directory and we
155
    // don't want to deploy them  -->  see also #199096 and #222924 for more details
156
    private Set<String> collectChildModuleNames(J2eeModule source) {
157
        final Set<String> childModuleNames = new HashSet<String>();
158
        if (source instanceof J2eeApplication) {
159
            for (J2eeModule module : ((J2eeApplication) source).getModules()) {
160
161
                // We have to use getUrl() --> it's the only method that take the
162
                // maven ear plugin fileNameMapping attribute into account
163
                String moduleURL = module.getUrl();
164
                if (moduleURL != null) {
165
                    moduleURL = moduleURL.substring(moduleURL.lastIndexOf("/") + 1); // NOI18N
166
                    childModuleNames.add(moduleURL);
167
                }
168
            }
169
        }
170
        return childModuleNames;
171
    }
172
150
    private boolean cleanup(File f) {
173
    private boolean cleanup(File f) {
151
        String [] chNames = f.list();
174
        String [] chNames = f.list();
152
        boolean deleted = true;
175
        boolean deleted = true;
Lines 162-168 Link Here
162
        return deleted;
185
        return deleted;
163
    }
186
    }
164
187
165
    private void _distribute(Iterator<J2eeModule.RootedEntry> rootedEntries, File dir) {
188
    private void _distribute(Iterator<J2eeModule.RootedEntry> rootedEntries, File dir, Set<String> childModuleNames) {
166
        FileLock lock = null;
189
        FileLock lock = null;
167
190
168
        try {
191
        try {
Lines 195-214 Link Here
195
                }
218
                }
196
            }
219
            }
197
220
198
            if (rootedEntries.hasNext()) {
221
            while (rootedEntries.hasNext()) {
199
                final FileObject root = rootedEntries.next().getFileObject();
222
                J2eeModule.RootedEntry entry = rootedEntries.next();
223
                String relativePath = entry.getRelativePath();
224
                FileObject sourceFO = entry.getFileObject();
200
225
201
                while (rootedEntries.hasNext()) {
226
                if (childModuleNames != null && childModuleNames.contains(relativePath) && sourceFO.isData()) {
202
                    J2eeModule.RootedEntry entry = rootedEntries.next();
227
                    continue;
203
                    String relativePath = entry.getRelativePath();
228
                }
204
                    FileObject sourceFO = entry.getFileObject();
229
205
                    if (sourceFO.isData() && isArchiveInRootDir(root, sourceFO)) {
230
                ServerFileDistributor.findOrCreateParentFolder(destRoot, relativePath);
206
                        continue;
231
                if (sourceFO.isData()) {
207
                    }
232
                    copyFile(sourceFO, dir, relativePath);
208
                    FileObject destFolder = ServerFileDistributor.findOrCreateParentFolder(destRoot, relativePath);
209
                    if (sourceFO.isData()) {
210
                        copyFile(sourceFO, dir, relativePath);
211
                    }
212
                }
233
                }
213
            }
234
            }
214
        } catch (Exception e) {
235
        } catch (Exception e) {
Lines 226-238 Link Here
226
        }
247
        }
227
    }
248
    }
228
249
229
    private boolean isArchiveInRootDir(FileObject root, FileObject sourceFO) {
230
        if (sourceFO.getParent().equals(root) && ("jar".equals(sourceFO.getExt()) || "war".equals(sourceFO.getExt()))) {
231
            return true;
232
        }
233
        return false;
234
    }
235
236
    //ServerProgress methods
250
    //ServerProgress methods
237
    private void setStatusDistributeRunning(String message) {
251
    private void setStatusDistributeRunning(String message) {
238
        notify(createRunningProgressEvent(CommandType.DISTRIBUTE, message));
252
        notify(createRunningProgressEvent(CommandType.DISTRIBUTE, message));

Return to bug 222924