Revision 9477

View differences:

org.gvsig.raster.tilecache/trunk/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/TileServerExplorer.java
47 47
import org.gvsig.fmap.dal.exception.RemoveException;
48 48
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
49 49
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
50
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer;
50 51
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
51 52
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
52 53
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
53 54

  
54
public class TileServerExplorer extends AbstractFilesystemServerExplorerProvider implements DataServerExplorerProvider {
55
public class TileServerExplorer extends AbstractDataServerExplorer implements DataServerExplorerProvider {
55 56
	public static final String               NAME                     = "TileServerExplorer";
56 57

  
57 58
	public TileServerExplorer() {
58

  
59
            super(null,null);
59 60
	}
60 61

  
61 62
	public TileServerExplorer(
62 63
			TileServerExplorerParameters parameters,
63 64
			DataServerExplorerProviderServices services)
64 65
			throws InitializeException {
66
            super(parameters, services);
65 67
	}
66 68

  
67
	public boolean canCreate() {
68
		return false;
69
	}
70

  
71
	public boolean canCreate(NewDataStoreParameters parameters) {
72
		return false;
73
	}
74

  
75
	public void create(NewDataStoreParameters parameters, boolean overwrite)
76
			throws CreateException {
77
		throw new UnsupportedOperationException();
78
	}
79

  
80
	public NewDataStoreParameters getCreateParameters() throws DataException {
81
		return null;
82
	}
83

  
84
	public void initialize(
85
			FilesystemServerExplorerProviderServices serverExplorer) {
86
	}
87

  
88 69
	public void remove(DataStoreParameters parameters) throws RemoveException {
89 70
		throw new UnsupportedOperationException();
90 71
	}
91 72

  
92
	public String getDataStoreProviderName() {
93
		return TileProvider.NAME;
94
	}
95

  
96
	/**
97
	 * When the source is a file then this method will check if exists a
98
	 * provider that can manage it
99
	 */
100
	public boolean accept(File pathname) {
101
		if (pathname.getParentFile() != null &&
102
				pathname.getParentFile().getName().equals("cellhd")) {
103
			if (pathname.getName().endsWith(".rmf")
104
					|| pathname.getName().endsWith(".rmf~")) {
105
				return false;
106
			}
107
			return true;
108
		}
109

  
110
		// Comprobamos que no sea un rmf propio, osea, que contenga xml
111
		if (pathname.getName().toLowerCase().endsWith(".rmf")) {
112
			FileInputStream reader = null;
113
			try {
114
				reader = new FileInputStream(pathname);
115
				String xml = "";
116
				for (int i = 0; i < 6; i++) {
117
					xml += (char) reader.read();
118
				}
119
				if (xml.equals("<?xml ")) {
120
					return false;
121
				}
122
			} catch (Exception e) {
123
			} finally {
124
				try {
125
					reader.close();
126
				} catch (Exception e) {
127
				}
128
			}
129
		}
130

  
131
		//The formats will be registered if it hasn't been done yet
132
		RasterLocator.getManager().getProviderServices().registerTileProviderFormats(TileProvider.class);
133

  
134
		return RasterLocator.getManager().getProviderServices().isExtensionSupported(
135
				pathname.getName(),
136
				TileProvider.class);
137
	}
138

  
139
	public String getDescription() {
140
		return TileProvider.DESCRIPTION;
141
	}
142

  
143
	public DataStoreParameters getParameters(File file) throws DataException {
144
		DataManager manager = DALLocator.getDataManager();
145
		AbstractRasterFileDataParameters params = (AbstractRasterFileDataParameters) manager
146
				.createStoreParameters(this.getDataStoreProviderName());
147
		params.setFile(file);
148
		return params;
149
	}
150

  
151 73
	public DataServerExplorerParameters getParameters() {
152 74
		return null;
153 75
	}
154 76

  
155
	public int getMode() {
156
		return DataServerExplorer.MODE_RASTER;
157
	}
158

  
159 77
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
160 78
		return null;
161 79
	}
......
197 115
		return null;
198 116
	}
199 117

  
200
	public void dispose() {
201

  
202
	}
203

  
204 118
    @Override
205 119
    public DataStoreParameters get(String name) throws DataException {
206
        File theFile = new File(name);
207
        DataStoreParameters dsp = this.getParameters(theFile);
208
        return dsp;
209

  
120
        return null;
210 121
    }
211 122

  
212
    /* (non-Javadoc)
213
     * @see org.gvsig.fmap.dal.DataServerExplorer#getResourcePath(org.gvsig.fmap.dal.DataStore, java.lang.String)
214
     */
215
    @Override
216
    public File getResourcePath(DataStore dataStore, String resourceName) throws DataException {
217
        String rootPathName = getResourceRootPathName(dataStore);
218
        if (rootPathName == null) {
219
            return null;
220
        }
221
        File f = new File(FilenameUtils.getPathNoEndSeparator(rootPathName),resourceName);
222
        if( f.exists() ) {
223
            return f;
224
        }
225
        return new File(rootPathName + "." + resourceName);
226
    }
227

  
228 123
}

Also available in: Unified diff