wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
package com.vci.client.fm;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
 
import com.vci.client.LogonApplication;
import com.vci.client.bof.BOFactoryClient;
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.bof.RevisionValueDelegate;
import com.vci.client.bof.RevisionValueObject;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.client.omd.provider.BtmProvider;
import com.vci.client.volumn.TransFileInfo;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.bofactory.BOFactoryService.UpdateBusinessObjectResult;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.atm.AttribItem;
import com.vci.corba.omd.btm.BtmItem;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.corba.volume.VolumeServicePrx;
import com.vci.corba.volume.data.FileInfo;
import com.vci.corba.framework.data.PvolumeInfo;
import com.vci.omd.constants.FileObjectType;
 
public class ClientFileObjectOperation implements ClientFOOperationInterface {
    private static VolumeServicePrx _vs = null;
    public static String fileSeparetor = ":";
    public static PvolumeInfo pvolumeInfo = null;
    
    public static VolumeServicePrx getVolumeDelegate(){
        if(_vs == null){
            _vs = ServiceProvider.getVolumeService(null);
        }
        return _vs;
    }
    
//    private int getTransmitBlockSize() {
//        int size = 0;
//        try {
//            size = (int)(ServiceProvider.getVolumeManager().getTransmitBlockSize() * 1024);
//        } catch (VCIError e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
//        
//        if (size == 0)
//            size = 32 * 1024;
//        
//        return size;
//    }
    
    @Override
    public FileObject createNewFile() throws VCIError{
        String boName = FileObjectType.FILE_DATA_TABLE;
        BtmItem item = this.getTypeInfo(boName);
        FileObject bo = new FileObject();
        bo.setOid(ObjectUtility.getNewObjectID36());
        bo.setRevisionid(ObjectUtility.getNewObjectID36());
        bo.setNameoid(ObjectUtility.getNewObjectID36());
        bo.setBtmName(boName);
        bo.setIsLastR(true);
        bo.setIsFirstR(true);
        bo.setIsFirstV(true);
        bo.setIsLastV(true);
        
        bo.setCreator(LogonApplication.getUserEntityObject().getUserName());
        bo.setCreateTime(System.currentTimeMillis());
        bo.setLastModifier(LogonApplication.getUserEntityObject().getUserName());
        bo.setLastModifyTime(System.currentTimeMillis());
        bo.setRevisionRule(item.revRuleName);
        bo.setVersionRule(String.valueOf(item.verRuleName));
        
        RevisionValueObject revisonObj = getRevisionSeqVal(item.revLevel, item.revRuleName, item.revInput);
        bo.setRevisionSeq(revisonObj.getRevisionSeq());
        bo.setRevisionValue(revisonObj.getRevisionVal());
        bo.setVersionSeq((short)1);
        bo.setVersionValue("1");
        
        bo.setLctId(item.lifeCycle);
        bo.setLcStatus(getLcFirstStatus(item.lifeCycle));
        bo.setId("");
        bo.setName("");
        bo.setDescription("");
        bo.setOwner(LogonApplication.getUserEntityObject().getUserName());
        //bo.setCheckinBy(LogonApplication.getUserEntityObject().getUserName());
        initTypeAttributeValue(bo);
        bo.setCopyFromVersion("");
        bo.setDocumentoid("");
        bo.setFilePath("");
        bo.setFileType("");
        bo.setRevisionLimit(7);
        return bo;
    }
    
    private void initTypeAttributeValue(ClientBusinessObject bo) throws VCIError {
        try {
            AttribItem[] items = BtmProvider.getInstance().getBtAbItems(bo.getBtmName());
            for (AttribItem item : items) {
                bo.setAttributeValue(item.name, item.defValue);    
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new VCIError();
        } catch (Throwable e) {
            e.printStackTrace();
            throw new VCIError();
        }
    }
    
    @Override
    public  FileObject createNewFile(String localfilePath, FileObject fileObject) throws VCIError{
        PvolumeInfo pvolumeInfo = getServerFilePath();
        String midFilePath = getStoreFilePath(fileObject.getOid(), fileObject.getFileType());
        fileObject.setFilePath(new StringBuffer(pvolumeInfo.name).append(fileSeparetor).append(midFilePath).toString());
        fileObject.dealFileObjectNullValue();
        String uploadFilePath = new StringBuffer(pvolumeInfo.path).append(midFilePath).toString();
        boolean rs = uploadFile(localfilePath, uploadFilePath);
        if (!rs) {
            return null;
        }
        try {
            //上传成功,存储结构化信息
            fileObject.dealFileObjectNullValue();
            BusinessObject bo = fileObject.getBusinessObject();
            BusinessObject businessObject = BOFactoryClient.getBOFactoryService().createBusinessObject(bo,false,false);
            fileObject.setBusinessObject(businessObject);
            return fileObject;
        } catch (VCIError e) {
            try {
                _vs.deleteFile(fileObject.getFilePath());
            } catch (VCIError ee) {
                ee.printStackTrace();
            }
            throw new VCIError(e.code, e.messages);
        }
    }
    
    @Override
    public  FileObject createNewFile(String localfilePath, FileObject fileObject, PvolumeInfo pvolumeInfo) throws VCIError{
        if (pvolumeInfo == null || pvolumeInfo.path == null || pvolumeInfo.path.equals("")) {
            pvolumeInfo = getServerFilePath();
        }
        String midFilePath = getStoreFilePath(fileObject.getOid(), fileObject.getFileType());
        fileObject.setFilePath(new StringBuffer(pvolumeInfo.name).append(fileSeparetor).append(midFilePath).toString());
        fileObject.dealFileObjectNullValue();
        String uploadFilePath = new StringBuffer(pvolumeInfo.path).append(midFilePath).toString();
        boolean rs = uploadFile(localfilePath, uploadFilePath);
        if (!rs) {
            return null;
        }
        try {
            //上传成功,存储结构化信息
            fileObject.dealFileObjectNullValue();
            BusinessObject bo = fileObject.getBusinessObject();
            BusinessObject businessObject = BOFactoryClient.getBOFactoryService().createBusinessObject(bo,false,false);
            fileObject.setBusinessObject(businessObject);
            return fileObject;
        } catch (VCIError e) {
            try {
                _vs.deleteFile(fileObject.getFilePath());
            } catch (VCIError ee) {
                ee.printStackTrace();
            }
            throw new VCIError(e.code, e.messages);
        }
    }
    
    @Override
    public  FileObject uploadFile(String localfilePath, FileObject fileObject) throws VCIError{
        PvolumeInfo pvolumeInfo = getServerFilePath();
        String midFilePath = getStoreFilePath(fileObject.getOid(), fileObject.getFileType());
        fileObject.setFilePath(new StringBuffer(pvolumeInfo.name).append(fileSeparetor).append(midFilePath).toString());
        fileObject.dealFileObjectNullValue();
        String uploadFilePath = new StringBuffer(pvolumeInfo.path).append(midFilePath).toString();
        boolean rs = uploadFile(localfilePath, uploadFilePath);
        if (!rs) {
            return null;
        }
        
        return fileObject;
    }
    
    /**
     * 获取的文件的卷服务配置
     * @return
     * @throws VCIError
     */
    public PvolumeInfo getServerFilePath() throws VCIError {
        if (pvolumeInfo != null) {
            return pvolumeInfo;
            
        }
        pvolumeInfo = ServiceProvider.getFrameService().getDefaultVolume();
        return pvolumeInfo;
    }
    
    private PvolumeInfo[] getAllVolume() throws VCIError {
        return ServiceProvider.getFrameService().getAllPvolumes();
    }
    
    @Override
    public String getFullFilePath(FileObject fileObject) throws VCIError {
        String str = fileObject.getFilePath();
        if (str.indexOf(fileSeparetor) < 0) {
            return str;
        }
        PvolumeInfo[] volumes = getAllVolume();
        if (volumes == null || volumes.length ==0) {
            return str;
        }
        PvolumeInfo volumeInfo = null;
        String volumnName = str.substring(0, str.indexOf(":"));
        for (int i = 0; i < volumes.length; i++) {
            if (volumnName.equals(volumes[i].name)) {
                volumeInfo = volumes[i];
                break;
            }
        }
        if (volumeInfo == null) {
            return str;
        }
        str = str.replace(volumeInfo.name + fileSeparetor, volumeInfo.path);
        return str;
    }
    
    @Override
    public boolean uploadFile(String localfilePath, String uploadFilePath) throws VCIError{
        boolean isSucess = true;
        try {
            File originalFile = new File(localfilePath);
            
            //存储非结构化信息
            _vs = getVolumeDelegate();
            isSucess = false;
            sendFile(_vs, originalFile, uploadFilePath);
            isSucess = true;
        } catch (VCIError e) {
            throw new VCIError(String.valueOf(e.code), e.messages);
        } finally {
            try {
                if (!isSucess) {
                    _vs.deleteFile(uploadFilePath);
                }
            } catch (VCIError e) {
                e.printStackTrace();
            }
        }
        return isSucess;
    }
    
    /**
     * 获取文件存储到服务器端的路径
     * @param fileId
     * @param fileType
     * @return
     * @throws VCIError 
     */
    public String getStoreFilePath(String fileId, String fileType) throws VCIError {
        StringBuffer desFileName = new StringBuffer();
        desFileName.append(FileCabinetPath.getRandomServerSaveFilePath());
        desFileName.append("/");
        desFileName.append(fileId);
        if (fileType.trim().length() > 0) {
            desFileName.append(".");
            desFileName.append(fileType);
        }
        
        String uploadFilePath = desFileName.toString();
        return uploadFilePath;
    }
    
    @Override
    public boolean deleteFileObject(String oid) throws VCIError{
        BusinessObject businessObject = BOFactoryClient.getBOFactoryService().readBusinessObject(oid, FileTypeConstants.FILE_DATA_TABLE);
        FileObject fileObject = new FileObject();
        fileObject.setBusinessObject(businessObject);
        boolean rs = BOFactoryClient.getBOFactoryService().deleteBusinessObject(fileObject.getBusinessObject(), 1);
        
        if(!rs){
            return false;
        }
        
        String serverPath = fileObject.getAttributeValue(FileTypeConstants.SELECT_FILEPATH);
        try {
            _vs = getVolumeDelegate();
            boolean isSucess = _vs.deleteFile(serverPath);
            if(isSucess == true){
                return true;
            }
        } catch (VCIError e) {
            throw new VCIError(String.valueOf(e.code), e.messages);
        }
        
        return false;
    }
    
    @Override
    public FileObject getFileObject(String id) throws VCIError {
        BusinessObject businessObject = BOFactoryClient.getBOFactoryService().readBusinessObject(id, FileTypeConstants.FILE_DATA_TABLE);
        FileObject fileObject = new FileObject();
        fileObject.setBusinessObject(businessObject);
        return fileObject;
    }
    
    @Override
    public boolean checkOutFileObject(FileObject fileObject) throws VCIError {
        fileObject.dealBusinessObjectNullValue();
        boolean rs = BOFactoryClient.getBOFactoryService().checkoutBusinessObject(fileObject.getBusinessObject());
        return rs;
    }
 
    @Override
    public boolean downLoadFile(String clientPath, String serverPath) throws VCIError{
        boolean rs = false;
        try {
            rs = receiveFile(_vs, new File(clientPath).getParent(), new File(clientPath).getName(), serverPath);
        } catch (VCIError e) {
            throw new VCIError(String.valueOf(e.code), e.messages);
        }
        return rs;
    }
    
    @Override
    public boolean downLoadFileByOid(String clientPath, String fileOid) throws VCIError {
        boolean rs = false;
        try {
            FileObject fileObject = this.getFileObject(fileOid);
            String serverPath = this.getFullFilePath(fileObject);
            rs = receiveFile(_vs, new File(clientPath).getParent(), new File(clientPath).getName(), serverPath);
        } catch (VCIError e) {
            throw new VCIError(String.valueOf(e.code), e.messages);
        }
        return rs;
    }
    
    @Override
    public boolean checkInFileObject(FileObject fileObject) throws VCIError{
        fileObject.dealFileObjectNullValue();
        boolean rs = BOFactoryClient.getBOFactoryService().checkInBusinessObject(fileObject.getBusinessObject());
        return rs;
    }
    
    @Override
    public boolean updateFileObject(FileObject fileObject) throws VCIError {
        fileObject.dealFileObjectNullValue();
 
        UpdateBusinessObjectResult result = BOFactoryClient.getBOFactoryService().updateBusinessObject(fileObject.getBusinessObject());
        return result.returnValue;
    }
    
 
    @Override
    public boolean undCheckOutFileObject(FileObject fileObject) throws VCIError {
        fileObject.dealFileObjectNullValue();
        boolean rs =  BOFactoryClient.getBOFactoryService().unCheckOutBusinessObject(fileObject.getBusinessObject());
        return rs;
    }
 
    @Override
    public FileObject reviseFileObject(FileObject fromFo,String revisionVal)
            throws VCIError {
        BtmItem item = this.getTypeInfo(fromFo.getBtmName());
        if (item.revLevel == 0) {
            throw new VCIError("P0010SOF-00015", new String[0]);
        }
        FileObject toFo = new FileObject();
        toFo.setOid(ObjectUtility.getNewObjectID36());
        toFo.setRevisionid(ObjectUtility.getNewObjectID36());
        toFo.setNameoid(fromFo.getNameoid());
        toFo.setBtmName(fromFo.getBtmName());
        toFo.setIsLastR(true);
        toFo.setIsFirstR(false);
        toFo.setIsFirstV(true);
        toFo.setIsLastV(true);
        
        toFo.setCreator(LogonApplication.getUserEntityObject().getUserName());
        toFo.setCreateTime(System.currentTimeMillis());
        toFo.setLastModifier(LogonApplication.getUserEntityObject().getUserName());
        toFo.setLastModifyTime(System.currentTimeMillis());
        toFo.setRevisionRule(item.revRuleName);
        toFo.setVersionRule(String.valueOf(item.verRuleName));
        RevisionValueObject rvObj = getNextRevision(fromFo.getBtmName(), fromFo.getNameoid(), item.revRuleName, item.revInput, revisionVal);
        toFo.setRevisionSeq(rvObj.getRevisionSeq());
        toFo.setRevisionValue(rvObj.getRevisionVal());
        
        
        toFo.setVersionSeq((short)1);
        toFo.setVersionValue("1");
        
        toFo.setLctId(fromFo.getLctId());
        toFo.setLcStatus(getLcFirstStatus(item.lifeCycle));
        toFo.setId(fromFo.getId());
        toFo.setName(fromFo.getName());
        toFo.setDescription(fromFo.getDescription());
        toFo.setOwner(LogonApplication.getUserEntityObject().getUserName());
        //toFo.setCheckinBy(LogonApplication.getUserEntityObject().getUserName());
        toFo.setCopyFromVersion(fromFo.getOid());
        String fromFilePath = fromFo.getFilePath();
        String toFilePath = fromFilePath.replaceAll(fromFo.getOid(), toFo.getOid());
        toFo.setFilePath(toFilePath);
        toFo.setFileType(fromFo.getFileType());
        toFo.dealBusinessObjectNullValue();
        
        //文件对象的升版需要同步复制一份源版本的物理文件作为新版本对应的物理文件。
        try {
            _vs = getVolumeDelegate();
            _vs.copyFile(fromFilePath, toFilePath);
        } catch (VCIError e) {
            throw new VCIError(String.valueOf(e.code), e.messages);
        }
        
        //存储生版对象
        BusinessObject toBusinessObject = BOFactoryClient.getBOFactoryService().createBusinessObject(toFo.getBusinessObject(), true, false);
        toFo.setBusinessObject(toBusinessObject);
        return toFo;
    }
    
    /**
     * 获取下一个版本号
     * @param boName
     * @param nameOid
     * @param revRuleName
     * @param revInput
     * @param revisionVal
     * @return
     * @throws VCIError
     */
    private RevisionValueObject getNextRevision(String btName, String nameOid, String revRuleName, boolean revInput, String revisionVal) throws VCIError {
        RevisionValueDelegate delegate = new RevisionValueDelegate();
        //String tableName = OmdTools.getBTTableName(boName);
        RevisionValueObject object = delegate.getNextRevisionValueObject(btName, nameOid, revRuleName, revInput, revisionVal);
        return object;
    }
    
    
    /**
     * 根据BO名称获取对象详细信息
     * @param boName
     * @return
     */
    private BtmItem getTypeInfo(String boName) {
        //BtmProvider provide = BtmProvider.getInstance();
        BtmItem item = BtmProvider.getBtmItemByName(boName);
        return item;
    }
    
    /**
     * 获取初始的版本信息
     * @param revLevel, 版本类型
     * @param revRuleName,版本规则名称
     * @return
     */
    private RevisionValueObject getRevisionSeqVal(int revLevel, String revRuleName, boolean revInput) {
        RevisionValueObject obj = new RevisionValueObject();
        obj.setRevisionSeq((short)1);
        if (revInput) {
            obj.setRevisionVal("");
            return obj;
        }
        if (revLevel == 0) {
            obj.setRevisionVal("-");
        } else {
            obj.setRevisionVal(getFirstRevision(revRuleName));
        }
        
        return obj;
    }
    
    
    
    /**
     * 获取第一个版本值
     * @param revRuleName
     * @return
     */
    private String getFirstRevision(String revRuleName) {
        String initValue;
        try {
            initValue = ServiceProvider.getOMDService().getVerRuleService().getVersionRule(revRuleName).initialValue;
            return initValue;
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return "";
    }
    
    /**
     * 根据生命周期名称获取第一个生命周期节点
     * @param lifeCycleName
     * @return
     */
    private String getLcFirstStatus(String lifeCycleName) {
        LifeCycle lc;
        try {
            lc = ServiceProvider.getOMDService().getLifeCycleService().getLifeCycle(lifeCycleName);
            String firstState = lc.startState;
            return firstState;
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        return "";
    }
    
    
    /**
     * 
     * <p>Description: 上传文件</p>
     * 
     * @author Administrator
     * @time 2011-7-3
     * @param originalFile:客户端文件
     * @param desFileName:服务器端文件名称
     * @return
     * @throws VCIError
     */
    private long sendFile(VolumeServicePrx vs, File originalFile, String desFileName) throws VCIError{
        
        if (!originalFile.exists()) {
            throw new VCIError("710020", new String[0]);
        }
        
        try {
            long currentTime = vs.getCurrrentTimeMillions();
            FileInputStream in = new FileInputStream(originalFile);
            long fileSize = originalFile.length();
            int blockSize = (int)vs.getTransmitBlockSize();
            if (blockSize < 0) {
                blockSize = 32 * 1024;
            }
            byte[] fileByte = new byte[blockSize];
            long temp = 0;
            while (temp < (fileSize - blockSize)) {
                in.read(fileByte, 0, blockSize);
                vs.receiveFile(desFileName, fileByte, temp, currentTime, fileSize);
                //added by xiong fei 2011-06-07
                TransFileInfo.setTotalSendedSize(blockSize);
                temp += blockSize;
            }
            int remainSize = (int)(fileSize - temp);
            fileByte = new byte[remainSize];
            in.read(fileByte, 0, remainSize);
            vs.receiveFile(desFileName, fileByte, temp, currentTime, fileSize);
            //added by xiong fei 2011-06-07
            TransFileInfo.setTotalSendedSize(remainSize);
            in.close();
            return currentTime;
        } catch (VCIError rme) {
            throw rme;
        } catch (Exception e) {
            throw new VCIError("710021", new String[0]);
        }
    }
    
    /**
     * 
     * <p>Description: 下载文件</p>
     * 
     * @author Administrator
     * @time 2011-7-3
     * @param directory:客户端文件路径
     * @param fileName:客户端文件名称
     * @param dowloadFileName:服务器端文件名称
     * @return
     * @throws VCIError
     */
    private boolean receiveFile(VolumeServicePrx vs, String directory, String fileName, String dowloadFileName) throws VCIError{
        boolean rs = false;
        try {
            long fileSize = vs.getFileSize(dowloadFileName);
            TransFileInfo.setFileLength(fileSize);
            File file = new File(directory, fileName);
            FileOutputStream filesave = new FileOutputStream(file);
            int blockSize = (int)vs.getTransmitBlockSize();
            long temp = 0;
            while (fileSize - temp > blockSize) {
                filesave.write(vs.sendFile(dowloadFileName, temp));
                //added by xiongfei 2011-06-09
                TransFileInfo.setTotalSendedSize(blockSize);
                temp += blockSize;
            }
            //added by xiongfei 2011-06-09
            TransFileInfo.setTotalSendedSize(blockSize);
            filesave.write(vs.sendFile(dowloadFileName, temp));
            filesave.flush();
            filesave.close();
            rs=true;
        } catch (VCIError re) {
            throw re;
        } catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("710018", new String[0]);
        }
        return rs;
    }
    
    /**
     * 
     * <p>Description: 下载文件</p>
     * 
     * @author Administrator
     * @time 2011-7-3
     * @param info
     * @param fName
     * @throws VCIError
     */
    private void receiveFile(VolumeServicePrx vs, FileInfo info, String fName) throws VCIError{
        try {
            String saveFileName = info.fileSavePath;
            long fileSize = info.fileSize;
            File file = new File(saveFileName);
            if(!file.exists()){
                 file.mkdirs();
                 if (!info.isDirectory) {
                     file.delete();
                 }
            }
            if (info.isDirectory) {
                return;
            }
            if (fileSize == 0) {
                return;
            }
            FileOutputStream filesave = new FileOutputStream(saveFileName);
            long blockSize = vs.getTransmitBlockSize();
            long temp = 0;
            String fileName = info.filePath;
            while (fileSize - temp > blockSize) {
                filesave.write(vs.sendFile(fileName, temp));
                temp += blockSize;
            }
            filesave.write(vs.sendFile(fileName, temp));
            filesave.flush();
            filesave.close();
        } catch (VCIError re) {
            throw re;
        } catch (Exception e) {
            throw new VCIError("710018", new String[0]);
        }
    }
    
}