Revision 1298

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/persistence/impl/AbstractPersistentState.java
108 108
	public void setFactory(PersistenceFactory factory) {
109 109
		this.factory = factory;
110 110
	}
111
	
111

  
112 112
	public DynStruct getDefinition() {
113 113
		DynStruct definition = this.factory.getDefinition(this.theClassName);
114 114
		return definition;
......
161 161
			return obj;
162 162
		}
163 163
		/*
164
		 * 
164
		 *
165 165
		 */
166 166
		if (obj instanceof List) {
167 167
			if ((manager.getFactories().get(obj)) == null) {
......
477 477
	/**
478 478
	 * Checks class of <code>theOriginal</code> and transforms it if is
479 479
	 * necessary.<br>
480
	 * 
480
	 *
481 481
	 * @param theOriginal
482 482
	 * @return
483 483
	 * @throws PersistenceException
......
620 620

  
621 621
	/*
622 622
	 * (non-Javadoc)
623
	 * 
623
	 *
624 624
	 * @see
625 625
	 * org.gvsig.tools.persistence.impl.ImplementationPersistentState#getId()
626 626
	 */
......
661 661

  
662 662
	/*
663 663
	 * (non-Javadoc)
664
	 * 
664
	 *
665 665
	 * @see org.gvsig.tools.persistence.impl.ImplementationPersistentState#
666 666
	 * setTheClassName(java.lang.String)
667 667
	 */
668 668
	public void setTheClassName(String className) {
669 669
		theClassName = className;
670 670
	}
671
	
671

  
672 672
	private void storeValues(Collection storage, Iterator iter)
673 673
			throws PersistenceException {
674 674
		while (iter.hasNext()) {
......
712 712

  
713 713
	/*
714 714
	 * (non-Javadoc)
715
	 * 
715
	 *
716 716
	 * @see
717 717
	 * org.gvsig.tools.persistence.impl.ImplementationPersistentState#getContext
718 718
	 * ()
......
727 727
	//
728 728
	/*
729 729
	 * (non-Javadoc)
730
	 * 
730
	 *
731 731
	 * @see
732 732
	 * org.gvsig.tools.persistence.impl.ImplementationPersistentState#hasValue
733 733
	 * (java.lang.String)
......
752 752
		DynStruct definition = manager.getDefinition(getTheClassName());
753 753
		return definition != null && definition.getDynField(name) != null;
754 754
	}
755
        
755

  
756 756
        private Object getDefaultValue(String name) {
757 757
		DynStruct definition = manager.getDefinition(getTheClassName());
758 758
                if( definition == null ) {
......
763 763
                }
764 764
		return definition.getDynField(name).getDefaultValue();
765 765
        }
766
	
766

  
767 767
	public void relativizeFiles(File rootFolder) {
768 768
		PersistentContext context = this.getContext();
769 769

  
......
841 841
			}
842 842
		}
843 843
	}
844
	
844

  
845 845
    public void derelativizeFiles(File rootFolder) {
846 846
        PersistentContext context = this.getContext();
847 847
        //URI cwd = new File(System.getProperty("user.dir")).toURI();
......
894 894
                        try {
895 895
                            URI value = aState.getURI(field.getName());
896 896
                            if (value.getScheme() == null || "FILE".equalsIgnoreCase(value.getScheme())) {
897
                                if (!value.getPath().startsWith("/")) {
898
                                    File file = FileUtils.toFile(value.toURL());
897
                                if (!value.isAbsolute() || !value.getPath().startsWith("/")) {
898
                                    File file;
899
                                    file = new File(value.getPath());
899 900
                                    file = FileTools.derelativizeFile(rootFolder, file);
900 901
                                    aState.set(field.getName(), file.toURI());
901 902
                                }
902 903
                            }
903 904
                        } catch (PersistenceException e) {
904 905
                            // do nothing
905
                        } catch (MalformedURLException ex) {
906
                            // do nothing
907 906
                        }
908 907
                    }
908

  
909

  
909 910
                }
910 911
            } catch (RuntimeException e) {
911 912
                logger.info("Can't fix relative paths in " + className, e);

Also available in: Unified diff