Revision 39207 branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/shp/SHPStoreProvider.java
SHPStoreProvider.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.dal.store.shp; |
29 | 29 |
|
30 |
import java.io.File; |
|
30 | 31 |
import java.io.IOException; |
31 | 32 |
import java.util.Iterator; |
32 | 33 |
|
34 |
import org.apache.commons.io.FileUtils; |
|
33 | 35 |
import org.cresques.cts.IProjection; |
34 | 36 |
import org.slf4j.Logger; |
35 | 37 |
import org.slf4j.LoggerFactory; |
36 | 38 |
|
37 |
import org.gvsig.fmap.crs.CRSFactory; |
|
38 | 39 |
import org.gvsig.fmap.dal.DataStore; |
39 | 40 |
import org.gvsig.fmap.dal.DataTypes; |
40 | 41 |
import org.gvsig.fmap.dal.FileHelper; |
... | ... | |
473 | 474 |
SHPStoreParameters shpParams = getShpParameters(); |
474 | 475 |
SHPStoreParameters tmpParams = |
475 | 476 |
(SHPStoreParameters) shpParams.getCopy(); |
476 |
tmpParams.setDBFFile(tmpParams.getDBFFileName() |
|
477 |
+ ".tmp"); |
|
478 |
tmpParams.setSHPFile(tmpParams.getSHPFileName() |
|
479 |
+ ".tmp"); |
|
480 |
tmpParams.setSHXFile(tmpParams.getSHXFileName() |
|
481 |
+ ".tmp"); |
|
477 |
|
|
478 |
File tmp_base = File.createTempFile( |
|
479 |
"tmp_" + System.currentTimeMillis(), null); |
|
480 |
String str_base = tmp_base.getCanonicalPath(); |
|
481 |
|
|
482 |
tmpParams.setDBFFile(str_base + ".dbf"); |
|
483 |
tmpParams.setSHPFile(str_base + ".shp"); |
|
484 |
tmpParams.setSHXFile(str_base + ".shx"); |
|
482 | 485 |
|
483 | 486 |
writer.begin(tmpParams, fType, dbfFtype, set.getSize()); |
484 | 487 |
|
... | ... | |
505 | 508 |
throw new PerformEditingException(getProviderName(), |
506 | 509 |
new IOException(shpParams.getSHXFileName())); |
507 | 510 |
} |
511 |
|
|
508 | 512 |
if (!tmpParams.getDBFFile().renameTo( |
509 | 513 |
shpParams.getDBFFile())) { |
510 |
throw new PerformEditingException(getProviderName(), |
|
511 |
new IOException(shpParams.getSHPFileName())); |
|
514 |
logger.info("Warning: copying tmp file instead of renaming: " |
|
515 |
+ shpParams.getDBFFile()); |
|
516 |
FileUtils.copyFile( |
|
517 |
tmpParams.getDBFFile(), |
|
518 |
shpParams.getDBFFile()); |
|
512 | 519 |
} |
513 | 520 |
if (!tmpParams.getSHPFile().renameTo( |
514 | 521 |
shpParams.getSHPFile())) { |
515 |
throw new PerformEditingException(getProviderName(), |
|
516 |
new IOException(shpParams.getSHPFileName())); |
|
522 |
logger.info("Warning: copying tmp file instead of renaming: " |
|
523 |
+ shpParams.getSHPFile()); |
|
524 |
FileUtils.copyFile( |
|
525 |
tmpParams.getSHPFile(), |
|
526 |
shpParams.getSHPFile()); |
|
517 | 527 |
} |
518 | 528 |
if (!tmpParams.getSHXFile().renameTo( |
519 | 529 |
shpParams.getSHXFile())) { |
520 |
throw new PerformEditingException(getProviderName(), |
|
521 |
new IOException(shpParams.getSHXFileName())); |
|
530 |
logger.info("Warning: copying tmp file instead of renaming: " |
|
531 |
+ shpParams.getSHXFile()); |
|
532 |
FileUtils.copyFile( |
|
533 |
tmpParams.getSHXFile(), |
|
534 |
shpParams.getSHXFile()); |
|
522 | 535 |
} |
523 | 536 |
|
524 | 537 |
resourcesNotifyChanges(); |
Also available in: Unified diff