Revision 42879

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/DefaultFeatureTypeDefinitionsManager.java
16 16
import org.gvsig.andami.PluginServices;
17 17
import org.gvsig.andami.PluginsLocator;
18 18
import org.gvsig.andami.PluginsManager;
19
import org.gvsig.fmap.dal.DataServerExplorer;
19 20
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
20 21
import org.gvsig.fmap.dal.feature.FeatureStore;
21 22
import org.gvsig.fmap.dal.feature.FeatureType;
22 23
import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager;
23 24
import org.gvsig.tools.ToolsLocator;
25
import org.gvsig.tools.dispose.DisposeUtils;
24 26
import org.gvsig.tools.dynobject.DynClass;
25 27
import org.gvsig.tools.dynobject.DynObjectManager;
26 28
import org.slf4j.Logger;
......
114 116
        }
115 117
        File definitionFile = getDefinitionFile(key);
116 118
        if (definitionFile == null) {
117
            return featureType;
119
            DataServerExplorer explorer = null;
120
            try {
121
                explorer = store.getExplorer();
122
                definitionFile = explorer.getResourcePath(store, key);
123
            } catch(Exception ex) {
124
                // Do nothing, leave definitionFile to null
125
            } finally {
126
                DisposeUtils.disposeQuietly(explorer);
127
            }
128
            if( definitionFile == null ) {
129
                return featureType;
130
            }
118 131
        }
119 132
        DynObjectManager dynObjectManager = ToolsLocator.getDynObjectManager();
120 133
        try {
121 134
            String xml = FileUtils.readFileToString(definitionFile);
122
            xml = xml.replaceAll("@@@",definitionFile.getParentFile().getAbsolutePath());
135
            xml = xml.replaceAll("[$][{]CWD[}]",definitionFile.getParentFile().getAbsolutePath());
123 136

  
124 137
            InputStream is = IOUtils.toInputStream(xml, Charset.forName("UTF-8"));
125 138
            Map<String, DynClass> dynClasses = dynObjectManager.importDynClassDefinitions(is, this.getClass().getClassLoader());
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataServerExplorer.java
23 23
 */
24 24
package org.gvsig.fmap.dal;
25 25

  
26
import java.io.File;
26 27
import java.util.List;
27 28

  
28 29
import org.gvsig.fmap.dal.exception.DataException;
......
152 153
	 */
153 154
	public List getDataStoreProviderNames();
154 155

  
156
        /**
157
         * Return the file resource associated to this name and store.
158
         * If the resource not exists or the explorer don't support this opperation
159
         * return null.
160
         * 
161
         * @param dataStore
162
         * @param resourceName
163
         * @return file resource or null
164
         * @throws DataException 
165
         */
166
        public File getResourcePath(DataStore dataStore, String resourceName) throws DataException;
167

  
155 168
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/AbstractDataServerExplorer.java
1 1
package org.gvsig.fmap.dal.spi;
2 2

  
3
import java.io.File;
3 4
import org.gvsig.fmap.dal.DataServerExplorer;
4 5
import org.gvsig.fmap.dal.DataServerExplorerParameters;
6
import org.gvsig.fmap.dal.DataStore;
5 7
import org.gvsig.fmap.dal.DataStoreParameters;
6 8
import org.gvsig.fmap.dal.exception.DataException;
7 9
import org.gvsig.tools.dispose.impl.AbstractDisposable;
......
36 38
        return null;
37 39
    }
38 40
    
41
    public File getResourcePath(DataStore dataStore, String resourceName) throws DataException {
42
        return null;
43
    }
44

  
39 45
    
40 46
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/FilesystemServerExplorer.java
29 29
import java.util.List;
30 30

  
31 31
import org.gvsig.fmap.dal.DataServerExplorer;
32
import org.gvsig.fmap.dal.DataStore;
33 32
import org.gvsig.fmap.dal.DataStoreParameters;
34 33
import org.gvsig.fmap.dal.NewDataStoreParameters;
35 34
import org.gvsig.fmap.dal.exception.DataException;
......
57 56
	public DataStoreParameters createStoreParameters(File file, String providerName) 
58 57
			throws DataException;
59 58

  
60
//	public DataStore open(File file) throws DataException,
61
//			ValidateDataParametersException;
62

  
63 59
	public Iterator getFilters();
64 60

  
65 61
	public Iterator getFilters(int mode);
......
67 63
	public FilesystemFileFilter getFilter(int mode, String description);
68 64
	
69 65
	public FilesystemFileFilter getGenericFilter();
70
	
71
	public File getResourcePath(DataStore dataStore, String resourceName) throws DataException;
72

  
73 66
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/AbstractFilesystemServerExplorerProvider.java
40 40
 */
41 41
public abstract class AbstractFilesystemServerExplorerProvider implements FilesystemServerExplorerProvider {
42 42

  
43
        @Override
43 44
	public String getResourceRootPathName(DataStore dataStore) {
44 45
		if (dataStore.getParameters().hasDynValue(FileResource.NAME)){
45 46
			Object obj = (dataStore.getParameters().getDynValue(FileResource.NAME));
......
59 60
		return file.getAbsolutePath();
60 61
	}
61 62
	
63
        @Override
62 64
	public int getMode() {
63 65
		return DataServerExplorer.MODE_ALL;
64 66
	}
65 67
	
68
        @Override
66 69
	public boolean isMode(int mode) {
67 70
		if( mode == DataServerExplorer.MODE_ALL ) {
68 71
			return true;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/DefaultFilesystemServerExplorer.java
28 28
import java.util.Iterator;
29 29
import java.util.List;
30 30
import java.util.Set;
31
import org.apache.commons.io.FilenameUtils;
31 32

  
32 33
import org.gvsig.fmap.dal.DALFileLocator;
33 34
import org.gvsig.fmap.dal.DALLocator;
......
493 494
        return newParams;
494 495
    }
495 496

  
497
    @Override
496 498
    public File getResourcePath(DataStore dataStore, String resourceName) throws DataException {
497 499
        FilesystemServerExplorerProvider provider
498 500
                = this.getProvider(dataStore.getProviderName());
499 501
        if (provider == null) {
500 502
            return null;
501 503
        }
502
        String rootPath = provider.getResourceRootPathName(dataStore);
503
        if (rootPath == null) {
504
        String rootPathName = provider.getResourceRootPathName(dataStore);
505
        if (rootPathName == null) {
504 506
            return null;
505 507
        }
506
        return new File(rootPath + "." + resourceName);
508
        File f = new File(FilenameUtils.getPathNoEndSeparator(rootPathName),resourceName);
509
        if( f.exists() ) {
510
            return f;
511
        }
512
        return new File(rootPathName + "." + resourceName);
507 513
    }
508 514

  
509 515
    @Override
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/impl/DefaultMapContextManager.java
71 71
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
72 72
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolPreferences;
73 73
import org.gvsig.tools.ToolsLocator;
74
import org.gvsig.tools.dispose.DisposeUtils;
74 75
import org.gvsig.tools.dynobject.exception.DynMethodException;
75 76
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
76 77
import org.gvsig.tools.observer.Notification;
......
688 689
            if (explorer == null) {
689 690
                return null;
690 691
            }
691
            return (File) call(explorer, "getResourcePath",
692
                    new Class[]{DataStore.class, String.class},
693
                    new Object[]{dataStore, resource});
692
            return explorer.getResourcePath(dataStore, resource);
694 693
        } catch (Exception e) {
695 694
            logger.warn(
696 695
                    "Can't locate a specific legend provided by the explorer "
697 696
                    + explorer, e);
698 697
            return null;
699 698
        } finally {
700
            if (explorer != null) {
701
                explorer.dispose();
702
                explorer = null;
703
            }
699
            DisposeUtils.disposeQuietly(explorer);
704 700
        }
705 701
    }
706 702

  

Also available in: Unified diff