Revision 43828 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/DefaultProject.java
DefaultProject.java | ||
---|---|---|
30 | 30 |
import java.io.FileInputStream; |
31 | 31 |
import java.io.FileNotFoundException; |
32 | 32 |
import java.io.FileOutputStream; |
33 |
import java.io.IOException; |
|
33 | 34 |
import java.io.InputStream; |
34 | 35 |
import java.io.OutputStream; |
35 | 36 |
import java.io.Serializable; |
... | ... | |
44 | 45 |
import java.util.List; |
45 | 46 |
import java.util.Map; |
46 | 47 |
import java.util.Set; |
48 |
import java.util.zip.ZipException; |
|
49 |
import java.util.zip.ZipFile; |
|
47 | 50 |
|
48 | 51 |
import org.cresques.cts.IProjection; |
49 | 52 |
|
... | ... | |
69 | 72 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
70 | 73 |
import org.gvsig.tools.ToolsLocator; |
71 | 74 |
import org.gvsig.tools.dynobject.DynStruct; |
72 |
import org.gvsig.tools.exception.ListBaseException; |
|
73 | 75 |
import org.gvsig.tools.observer.ObservableHelper; |
74 | 76 |
import org.gvsig.tools.observer.Observer; |
75 | 77 |
import org.gvsig.tools.persistence.PersistenceManager; |
... | ... | |
542 | 544 |
} catch (FileNotFoundException e) { |
543 | 545 |
throw new PersistenceException(e); |
544 | 546 |
} |
547 |
if( !isValidZIP(out) ) { |
|
548 |
throw new PersistenceException(new ZipException()); |
|
549 |
} |
|
545 | 550 |
this.fname = out; |
546 | 551 |
notifyObservers(ProjectNotification.AFTER_SAVE_TO_FILE, out); |
547 | 552 |
} |
548 | 553 |
|
554 |
boolean isValidZIP(final File file) { |
|
555 |
ZipFile zipfile = null; |
|
556 |
try { |
|
557 |
zipfile = new ZipFile(file); |
|
558 |
return true; |
|
559 |
} catch (IOException e) { |
|
560 |
return false; |
|
561 |
} finally { |
|
562 |
try { |
|
563 |
if (zipfile != null) { |
|
564 |
zipfile.close(); |
|
565 |
zipfile = null; |
|
566 |
} |
|
567 |
} catch (IOException e) { |
|
568 |
} |
|
569 |
} |
|
570 |
} |
|
571 |
|
|
549 | 572 |
public File getFile() { |
550 | 573 |
return this.fname; |
551 | 574 |
} |
Also available in: Unified diff