Revision 39204 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/DefaultProject.java
DefaultProject.java | ||
---|---|---|
606 | 606 |
} catch (URISyntaxException e) { |
607 | 607 |
// do nothind |
608 | 608 |
} |
609 |
} else if (field.getType() == DataTypes.URI) { |
|
610 |
try { |
|
611 |
URI value = aState.getURI(field.getName()); |
|
612 |
if (value.getScheme() == null || "FILE".equalsIgnoreCase(value.getScheme())) { |
|
613 |
File file = new File(value.getPath()); |
|
614 |
if (differentDrives(file, rootFolder)) { |
|
615 |
/* |
|
616 |
* Different drives |
|
617 |
* (should happen only in Windows) |
|
618 |
*/ |
|
619 |
value = file.toURI(); |
|
620 |
} else { |
|
621 |
/* |
|
622 |
* Both in the Same drive (C: D: etc) or Unix-style |
|
623 |
*/ |
|
624 |
file = relativizeFile(file, rootFolder); |
|
625 |
value = new URI(file.getPath()); |
|
626 |
} |
|
627 |
aState.set(field.getName(), value); |
|
628 |
} |
|
629 |
} catch (PersistenceException e) { |
|
630 |
// do nothind |
|
631 |
} catch (URISyntaxException e) { |
|
632 |
// do nothind |
|
633 |
} |
|
609 | 634 |
} |
610 | 635 |
} |
611 | 636 |
} |
... | ... | |
717 | 742 |
|
718 | 743 |
@SuppressWarnings("unchecked") |
719 | 744 |
Iterator<PersistentState> statesIterator = context.iterator(); |
745 |
String className = null; |
|
746 |
|
|
720 | 747 |
while (statesIterator.hasNext()) { |
721 | 748 |
PersistentState aState = statesIterator.next(); |
722 |
DynStruct definition = aState.getDefinition(); |
|
723 |
DynField[] fields = definition.getDynFields(); |
|
724 |
for (DynField field : fields) { |
|
725 |
if (field.getType() == DataTypes.FILE |
|
726 |
|| field.getType() == DataTypes.FOLDER) { |
|
727 |
try { |
|
728 |
File value = aState.getFile(field.getName()); |
|
729 |
value = fixFile(value, rootFolder); |
|
730 |
aState.set(field.getName(), value); |
|
731 |
} catch (PersistenceException e) { |
|
732 |
LOG.warn( |
|
733 |
"Can't fix field '" + field.getName() |
|
734 |
+ "' for class '" |
|
735 |
+ definition.getName() + "'.", e); |
|
736 |
} |
|
737 |
} else if (field.getType() == DataTypes.URL) { |
|
738 |
try { |
|
739 |
URL value = aState.getURL(field.getName()); |
|
740 |
if ("FILE".equalsIgnoreCase(value.getProtocol())) { |
|
741 |
if (!value.getFile().startsWith("/")){ |
|
742 |
value = new URL("file","",cwd.getRawPath()+value.getFile()); |
|
743 |
File file = new File(value.toURI().getPath().substring(cwd.getPath().length())); |
|
744 |
file = fixFile(file, rootFolder); |
|
745 |
aState.set(field.getName(), file.toURI().toURL()); |
|
749 |
try { |
|
750 |
className = aState.getTheClassName(); |
|
751 |
} catch (Throwable e) { |
|
752 |
className = "Unknown"; |
|
753 |
} |
|
754 |
try { |
|
755 |
DynStruct definition = aState.getDefinition(); |
|
756 |
DynField[] fields = definition.getDynFields(); |
|
757 |
for (DynField field : fields) { |
|
758 |
if (field.getType() == DataTypes.FILE |
|
759 |
|| field.getType() == DataTypes.FOLDER) { |
|
760 |
try { |
|
761 |
File value = aState.getFile(field.getName()); |
|
762 |
value = fixFile(value, rootFolder); |
|
763 |
aState.set(field.getName(), value); |
|
764 |
} catch (PersistenceException e) { |
|
765 |
LOG.warn( |
|
766 |
"Can't fix field '" + field.getName() |
|
767 |
+ "' for class '" |
|
768 |
+ definition.getName() + "'.", e); |
|
769 |
} |
|
770 |
} else if (field.getType() == DataTypes.URL) { |
|
771 |
try { |
|
772 |
URL value = aState.getURL(field.getName()); |
|
773 |
if ("FILE".equalsIgnoreCase(value.getProtocol())) { |
|
774 |
if (!value.getFile().startsWith("/")){ |
|
775 |
value = new URL("file","",cwd.getRawPath()+value.getFile()); |
|
776 |
File file = new File(value.toURI().getPath().substring(cwd.getPath().length())); |
|
777 |
file = fixFile(file, rootFolder); |
|
778 |
aState.set(field.getName(), file.toURI().toURL()); |
|
779 |
} |
|
746 | 780 |
} |
781 |
} catch (PersistenceException e) { |
|
782 |
// do nothing |
|
783 |
} catch (MalformedURLException e) { |
|
784 |
// do nothing |
|
785 |
} catch (URISyntaxException e) { |
|
786 |
// do nothing |
|
747 | 787 |
} |
748 |
} catch (PersistenceException e) { |
|
749 |
// do nothing |
|
750 |
} catch (MalformedURLException e) { |
|
751 |
// do nothing |
|
752 |
} catch (URISyntaxException e) { |
|
753 |
// do nothing |
|
788 |
|
|
789 |
} else if (field.getType() == DataTypes.URI) { |
|
790 |
try { |
|
791 |
URI value = aState.getURI(field.getName()); |
|
792 |
if (value.getScheme() == null || "FILE".equalsIgnoreCase(value.getScheme())) { |
|
793 |
if (!value.getPath().startsWith("/")){ |
|
794 |
File file = new File(value.getPath()); |
|
795 |
file = fixFile(file, rootFolder); |
|
796 |
aState.set(field.getName(), file.toURI()); |
|
797 |
} |
|
798 |
} |
|
799 |
} catch (PersistenceException e) { |
|
800 |
// do nothing |
|
801 |
} |
|
754 | 802 |
} |
755 |
|
|
756 | 803 |
} |
804 |
}catch (RuntimeException e) { |
|
805 |
logger.info("Can't fix relative paths in " + className, e); |
|
757 | 806 |
} |
758 | 807 |
} |
759 | 808 |
} |
Also available in: Unified diff