View | Details | Raw Unified | Return to bug 198046 | Differences between
and this patch

Collapse All | Expand All

(-)miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java (-7 / +44 lines)
Lines 19-24 Link Here
19
 * Xuan Chen (IBM)        - [191280] [dstore] Expand fails for folder "/folk" with 3361 children
19
 * Xuan Chen (IBM)        - [191280] [dstore] Expand fails for folder "/folk" with 3361 children
20
 * Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space
20
 * Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space
21
 * Kevin Doyle (IBM) - [196211] DStore Move tries rename if that fails copy/delete
21
 * Kevin Doyle (IBM) - [196211] DStore Move tries rename if that fails copy/delete
22
 * Xuan Chen (IBM)        - [198046] [dstore] Cannot copy a folder into an archive file
22
 *******************************************************************************/
23
 *******************************************************************************/
23
24
24
package org.eclipse.rse.dstore.universal.miners;
25
package org.eclipse.rse.dstore.universal.miners;
Lines 26-31 Link Here
26
import java.io.IOException;
27
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.InputStream;
28
import java.net.ServerSocket;
29
import java.net.ServerSocket;
30
import java.util.ArrayList;
29
import java.util.HashMap;
31
import java.util.HashMap;
30
import java.util.Iterator;
32
import java.util.Iterator;
31
import java.util.List;
33
import java.util.List;
Lines 228-233 Link Here
228
		    // if target is virtual or an archive, insert into an archive
230
		    // if target is virtual or an archive, insert into an archive
229
			AbsoluteVirtualPath vpath = getAbsoluteVirtualPath(targetFolder);
231
			AbsoluteVirtualPath vpath = getAbsoluteVirtualPath(targetFolder);
230
			ISystemArchiveHandler handler = getArchiveHandlerFor(vpath.getContainingArchiveString());
232
			ISystemArchiveHandler handler = getArchiveHandlerFor(vpath.getContainingArchiveString());
233
			boolean result = true;
231
			
234
			
232
			if (handler == null) 
235
			if (handler == null) 
233
			{
236
			{
Lines 237-242 Link Here
237
240
238
			File[] srcFiles = new File[numOfSources];
241
			File[] srcFiles = new File[numOfSources];
239
			String[] names = new String[numOfSources];
242
			String[] names = new String[numOfSources];
243
			ArrayList nonDirectoryArrayList = new ArrayList();
244
			ArrayList nonDirectoryNamesArrayList = new ArrayList();
245
			
246
			String virtualContainer = ""; //$NON-NLS-1$
247
			
248
			if (targetType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR)) 
249
			{
250
				virtualContainer = vpath.getVirtualPart();
251
			}
240
			
252
			
241
			for (int i = 0; i < numOfSources; i++)
253
			for (int i = 0; i < numOfSources; i++)
242
			{
254
			{
Lines 263-282 Link Here
263
					VirtualChild child = shandler.getVirtualFile(svpath.getVirtualPart());
275
					VirtualChild child = shandler.getVirtualFile(svpath.getVirtualPart());
264
					srcFiles[i] = child.getExtractedFile();
276
					srcFiles[i] = child.getExtractedFile();
265
				}
277
				}
278
				
279
				//If this source file object is directory, we will call ISystemArchiveHandler#add(File ...) method to 
280
				//it and all its descendants into the archive file.
281
				//If this source file object is not a directory, we will add it into a list, and then
282
				//call ISystemArchiveHandler#add(File[] ...) to add them in batch.
283
				if (srcFiles[i].isDirectory())
284
				{
285
					result = handler.add(srcFiles[i], virtualContainer, names[i]);
286
					if (result == false) {
287
						status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
288
						return statusDone(status);
289
					}
290
				}
291
				else
292
				{
293
					nonDirectoryArrayList.add(srcFiles[i]);
294
					nonDirectoryNamesArrayList.add(names[i]);
295
				}
266
			}
296
			}
267
			String virtualContainer = ""; //$NON-NLS-1$
268
			
297
			
269
			if (targetType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR)) 
298
			if (nonDirectoryArrayList.size() > 0)
270
			{
299
			{
271
				virtualContainer = vpath.getVirtualPart();
300
				File[] resultFiles = new File[nonDirectoryArrayList.size()];
301
				String[] resultNames = new String[nonDirectoryNamesArrayList.size()];
302
				for (int i=0; i<nonDirectoryArrayList.size(); i++)
303
				{
304
					resultFiles[i] = (File)nonDirectoryArrayList.get(i);
305
					resultNames[i] = (String)nonDirectoryNamesArrayList.get(i);
306
				}
307
				//we need to add those files into the archive file as well.
308
				result = handler.add(resultFiles, virtualContainer, resultNames);
272
			}
309
			}
273
274
			boolean result = handler.add(srcFiles, virtualContainer, names);
275
			
310
			
276
			if (result) {
311
			if (true == result)
312
			{
277
				status.setAttribute(DE.A_SOURCE, IServiceConstants.SUCCESS);
313
				status.setAttribute(DE.A_SOURCE, IServiceConstants.SUCCESS);
278
			}
314
			}
279
			else {
315
			else
316
			{
280
				status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
317
				status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED);
281
			}
318
			}
282
			return statusDone(status);
319
			return statusDone(status);

Return to bug 198046