Index: DefaultRasterStore.java
===================================================================
--- DefaultRasterStore.java	(revision 4180)
+++ DefaultRasterStore.java	(revision 4181)
@@ -5,11 +5,13 @@
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.io.File;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
 import org.cresques.cts.IProjection;
+
 import org.gvsig.compat.net.ICancellable;
 import org.gvsig.fmap.crs.CRSFactory;
 import org.gvsig.fmap.dal.DALLocator;
@@ -78,6 +80,7 @@
 import org.gvsig.tools.persistence.PersistenceManager;
 import org.gvsig.tools.persistence.PersistentState;
 import org.gvsig.tools.persistence.exception.PersistenceException;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -90,25 +93,25 @@
 	public static final String              PERSISTENT_NAME        = "DefaultRasterStore_Persistent";
     public static final String              PERSISTENT_DESCRIPTION = "DefaultRasterStore Persistent";
     private static final Logger             logger                 = LoggerFactory.getLogger(DefaultRasterStore.class);
-	
+
 	/*
-	 * TODO: Refactoring de ROIS 
+	 * TODO: Refactoring de ROIS
 	 * Una capa ráster debería poder tener ROIs de tipo ráster y de tipo vectorial asociados. Además
 	 * debe poder tener una lista de estos por lo que sería necesario un interfaz en la que se pueda
 	 * seleccionar la capa de ROIs a utilizar.
-	 * 
+	 *
 	 * Por otro lado, las ROIs deben ser del proveedor de datos. Este con tendrá una lista de estos.
-	 * Las ROIs deberían modelarse como proveedores de datos de tipo ráster o de tipo vectorial, ya que 
+	 * Las ROIs deberían modelarse como proveedores de datos de tipo ráster o de tipo vectorial, ya que
 	 * tener una lista de geometrías en memoria como hasta ahora puede ser muy poco eficiente en caso
 	 * de que la lista de ROIs sea muy grande. Además debería optimizarse el acceso isInside para que las
 	 * operaciones con ROIs asociados sean lo más rápidas posible.
 	 */
 	private List<ROI>                        rois                           = null;
-	
+
 	public DefaultRasterStore() {
 		super();
 	}
-	
+
 	public void reload() {
 		provider.reload();
 	}
@@ -118,22 +121,22 @@
 		parameters = (DataStoreParameters)provider.getDataParameters();
 		initializeBandList();
 	}
-	
+
 	public void setParameters(DataStoreParameters p) {
 		this.parameters = p;
 	}
-	
+
 	public void setProvider(CoverageStoreProvider prov) {
 		if(prov instanceof RasterProvider)
 			setProvider((RasterProvider)prov);
 	}
-	
+
 	public String getName() {
 		if(provider != null)
 			return provider.getName();
 		return null;
 	}
-	
+
 	public boolean needEnhanced() {
 		if(provider != null)
 			return provider.needEnhanced();
@@ -143,11 +146,11 @@
 	public boolean isTiled() {
 		return provider.isTiled();
 	}
-	
+
 	public boolean isMosaic() {
 		return provider.isMosaic();
 	}
-	
+
 	public Tile getTile(SpiRasterQuery q) throws TileGettingException {
 		TiledRasterProvider tiledProv = ((TiledRasterProvider)provider);
 		return tiledProv.getTile(q);
@@ -167,7 +170,7 @@
 			long[] fSize = provider.getFileSizeByProvider();
 			if(fSize != null && fSize.length > 0) {
 				for (int j = 0; j < fSize.length; j++) {
-					size += fSize[j];	
+					size += fSize[j];
 				}
 			}
 			return size;
@@ -283,14 +286,14 @@
 	public ColorTable getColorTables() {
 		return provider.getColorTable();
 	}
-	
+
 	public ColorTable getColorTable() {
 		//Solo tiene sentido si tiene un fichero y ese fichero tiene una sola banda
 		if(provider != null)
 			return provider.getColorTable();
 		return null;
 	}
-	
+
 	/**
 	 * Sets the color table
 	 * @param colorTable
@@ -338,7 +341,7 @@
 			return provider.isInside(p);
 		return false;
 	}
-	
+
 	public RasterDataStore getDataStore() {
 		return this;
 	}
@@ -373,7 +376,7 @@
 	public void setDrawableBands(int[] db) {
 		getBands().setDrawableBands(db);
 	}
-	
+
 	public int[] getDrawableBands() {
 		return getBands().getDrawableBands();
 	}
@@ -389,11 +392,11 @@
 	public void deleteLayerFromCache() {
 		provider.deleteLayerFromCache();
 	}
-	
+
 	public boolean isMultiFile() {
 		return provider.isMultiFile();
 	}
-	
+
 	public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException {
 		return provider.getOverviewWidth(band, overview);
 	}
@@ -413,11 +416,11 @@
 			return provider.isOverviewsSupported();
 		return false;
 	}
-	
+
 	public void saveGeoreferencingToRmf() throws RmfSerializerException {
 		provider.saveObjectToRmf(AbstractRasterProvider.class, provider);
 	}
-	
+
 	public void saveSerialInfoToRmf(TimeSeries serialInfo) throws RmfSerializerException {
 		provider.saveObjectToRmf(TimeSeries.class, serialInfo);
 	}
@@ -425,15 +428,15 @@
 	public void saveColorTableToRmf(ColorTable table) throws RmfSerializerException {
 		provider.saveObjectToRmf(ColorTable.class, table);
 	}
-	
+
 	public void saveGeoPointListToRmf(GeoPointList pointList) throws RmfSerializerException {
 		provider.saveObjectToRmf(GeoPointList.class, pointList);
 	}
-	
+
 	public void saveROIFileListToRmf(List<File> fileList) throws RmfSerializerException {
 		provider.saveObjectToRmf(List.class, fileList);
 	}
-	
+
 	public List<File> getROIFileListFromRmf() {
 		try {
 			List<File> fileList = new ArrayList<File>();
@@ -443,7 +446,7 @@
 		}
 		return null;
 	}
-	
+
 	public boolean loadSerialInfoFromRmf(TimeSeries serialInfo) {
 		try {
 			provider.loadObjectFromRmf(TimeSeries.class, serialInfo);
@@ -459,19 +462,19 @@
 			return provider.getView();
 		return null;
 	}
-	
+
 	public Extent getExtentWithoutRot() {
 		if(provider != null)
 			return provider.getExtentWithoutRot();
 		return null;
 	}
-	
+
 	public AffineTransform getOwnAffineTransform() {
 		if(provider != null)
 			return provider.getOwnAffineTransform();
 		return null;
 	}
-	
+
 	public AffineTransform getAffineTransform() {
 		if(provider != null) {
 			AffineTransform at = provider.getAffineTransform();
@@ -483,52 +486,52 @@
 				double sX = scale.getX() - translate.getX();
 				double sY = scale.getY() - translate.getY();
 				at = new AffineTransform(
-						sX, 
-						at.getShearY(), 
-						at.getShearX(), 
-						sY, 
-						translate.getX(), 
+						sX,
+						at.getShearY(),
+						at.getShearX(),
+						sY,
+						translate.getX(),
 						translate.getY());
 			}*/
 			return at;
 		}
 		return null;
 	}
-	
+
 	public IProjection getProjection() {
 		if(provider != null)
 			return provider.getProjection();
 		return null;
 	}
-	
+
 	public void setProjection(IProjection proj, boolean persist) throws RmfSerializerException {
 		if(provider != null)
 			provider.setProjection(proj, persist);
 	}
-	
+
 	public Statistics getStatistics() {
 		if(provider != null)
 			return provider.getStatistics();
 		return null;
 	}
-	
+
 	public void setStatistics(Statistics stats) throws RmfSerializerException {
 		if(provider != null)
 			provider.setStatistics(stats);
 	}
-	
+
 	public HistogramComputer getHistogramComputer() {
 		if(provider != null)
 			return provider.getHistogramComputer();
 		return null;
 	}
-	
+
 	public Metadata getMetadata() {
 		if(provider != null)
 			return provider.getMetadata();
 		return null;
 	}
-	
+
 	public Transparency getTransparency() {
 		if(provider != null) {
 			provider.getTransparency().setNoData(getNoDataValue());
@@ -536,11 +539,11 @@
 		}
 		return null;
 	}
-	
+
 	public ColorInterpretation getColorInterpretation() {
 		return provider.getColorInterpretation();
 	}
-	
+
 	public void setColorInterpretation(ColorInterpretation ci) {
 		provider.setColorInterpretation(ci);
 	}
@@ -550,27 +553,27 @@
 			return (provider.isReproyectable());
 		return false;
 	}
-	
+
 	public String getMetadataName() {
 		if(provider != null)
 			return provider.getName();
 		return null;
 	}
-	
+
 	public RasterDataStore cloneDataStore() throws CloneException {
 		DefaultRasterStore ds = new DefaultRasterStore();
 		ds.parameters = getParameters();
 		ds.provider = provider.cloneProvider();
-		
+
 		int[] bands = new int[1];
 		bands[0] = provider.getBandCount();
 		ds.metadata = new MultiDataStoreMetadata(bands);
 		((MultiDataStoreMetadata)ds.metadata).add(provider.getMetadata());
-		
+
 		ds.storeBandList = (BandListImpl)storeBandList.clone();
 		return ds;
 	}
-	
+
 	public boolean isOpen() {
 		if(provider == null)
 			return false;
@@ -580,11 +583,11 @@
 	public CoverageStoreProvider getProvider() {
 		return provider;
 	}
-	
+
 	public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException {
 		return ((RasterProvider)getProvider()).getInfoByPoint(x, y, cancellable);
 	}
-	
+
 	public String getInfoByPoint(double x, double y, Extent bbox, int w, int h, ICancellable cancellable) throws InfoByPointException {
 		return ((RasterProvider)getProvider()).getInfoByPoint((int)x, (int)y, bbox, w, h, cancellable);
 	}
@@ -612,13 +615,13 @@
 			((MultiDimensionalStoreParameters)getParameters()).selectPrevInstant();
 		}
 	}
-	
+
 	public void setTime(Time time) throws TimeException, OperationNotSupportedException {
 		if(!isTimeSupportedByTheProvider())
 			throw new OperationNotSupportedException("Not supported for a RasterDataset");
-		
+
 	}
-	
+
 	/**
 	 * Returns true whether all providers support time
 	 * @return
@@ -628,7 +631,7 @@
 			return provider.isTimeSupported();
 		return false;
 	}
-	
+
 	public boolean isRasterEnclosed() {
 		if(provider != null)
 			return provider.isRasterEnclosed();
@@ -666,7 +669,7 @@
 			return -1;
 		}
 	}
-	
+
 	public void setTileServer(Class<?> tileServer) throws InitializeException {
 		if(provider instanceof TiledRasterProvider) {
 			((TiledRasterProvider)provider).setTileServer(tileServer);
@@ -701,7 +704,7 @@
 		}
 		return null;
 	}
-	
+
 	public RasterDataStore newNotTiledDataStore() {
 		if(provider != null) {
 			RasterManager manager = (DefaultRasterManager)RasterLocator.getManager();
@@ -710,8 +713,8 @@
 				DataStoreParameters newParams = (DataStoreParameters)parameters;
 				if(this.isTiled()) {
 					newParams = ((TiledRasterProvider)getProvider()).getInternalProvider().getDataParameters();
-				} 
-				
+				}
+
 				newDataStore = manager.getProviderServices().open(newParams);
 				if(newDataStore instanceof DefaultRasterStore) {
 					((DefaultRasterStore)newDataStore).setStatistics(getStatistics());
@@ -728,7 +731,7 @@
 		return null;
 	}
 
-	public String[] getURIByProvider() {
+	public URI[] getURIByProvider() {
 		return provider.getURIByProvider();
 	}
 
@@ -739,27 +742,27 @@
 	public int getProviderCount() {
 		return provider.getInternalProviderCount();
 	}
-	
+
 	public int[] getBandCountByProvider() {
 		return provider.getBandCountByProvider();
 	}
-	
+
 	public RasterDataParameters[] getDataParametersByProvider() {
 		RasterDataParameters[] res = new RasterDataParameters[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
-			res[i] = (RasterDataParameters)provider.getInternalProvider(i).getDataParameters();			
+			res[i] = (RasterDataParameters)provider.getInternalProvider(i).getDataParameters();
 		}
 		return res;
 	}
-	
+
 	public Metadata[] getMetadataByProvider() {
 		Metadata[] res = new Metadata[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
-			res[i] = provider.getInternalProvider(i).getMetadata();			
+			res[i] = provider.getInternalProvider(i).getMetadata();
 		}
 		return res;
 	}
-	
+
 	public int[] getOverviewCountByProvider(int band) throws BandAccessException {
 		int[] res = new int[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
@@ -767,25 +770,25 @@
 				res[i] = provider.getInternalProvider(i).getOverviewCount(band);
 			} catch (RasterDriverException e) {
 				throw new BandAccessException("", e);
-			}			
+			}
 		}
 		return res;
 	}
-	
+
 	public String[] getOverviewSizeByProvider(int band, int overview) throws BandAccessException {
 		String[] res = new String[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
 			try {
-				res[i] = provider.getInternalProvider(i).getOverviewWidth(band, overview) + 
-						 "x" + 
+				res[i] = provider.getInternalProvider(i).getOverviewWidth(band, overview) +
+						 "x" +
 						 provider.getInternalProvider(i).getOverviewHeight(band, overview);
 			} catch (RasterDriverException e) {
 				throw new BandAccessException("", e);
-			}			
+			}
 		}
 		return res;
 	}
-	
+
 	public AffineTransform[] getAffineTransformByProvider() {
 		AffineTransform[] res = new AffineTransform[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
@@ -793,7 +796,7 @@
 		}
 		return res;
 	}
-	
+
 	public double[] getHeightByProvider() {
 		double[] res = new double[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
@@ -801,7 +804,7 @@
 		}
 		return res;
 	}
-	
+
 	public double[] getWidthByProvider() {
 		double[] res = new double[getProviderCount()];
 		for (int i = 0; i < res.length; i++) {
@@ -809,24 +812,24 @@
 		}
 		return res;
 	}
-	
-	public void addFile(String file) throws InvalidSourceException {
+
+	public void addFile(File file) throws InvalidSourceException {
 		provider.addFile(file);
 	}
-	
-	public void removeFile(String file) {
+
+	public void removeFile(File file) {
 		provider.removeFile(file);
-		storeBandList.removeBands(file);
+		storeBandList.removeBands(file.getPath());
 	}
-	
-	public String getURIByBand(int band) {
+
+	public URI getURIByBand(int band) {
 		return provider.getURIByBand(band);
 	}
-	
+
 	/**
 	 * Gets the {@link Interval} of the store, that means the temporal
 	 * interval where the store has valid data.
-	 * In raster this method has sense in a mosaic. Therefore this has to be implemented 
+	 * In raster this method has sense in a mosaic. Therefore this has to be implemented
 	 * by the provider.
 	 * @return
 	 *         a time interval or null if there is not time support
@@ -834,10 +837,10 @@
 	public Interval getInterval() {
 		return provider.getInterval();
 	}
-	
+
 	/**
-	 * Gets all the possible values of time for which the store has data.  
-	 * In raster this method has sense in a mosaic. Therefore this has to be implemented 
+	 * Gets all the possible values of time for which the store has data.
+	 * In raster this method has sense in a mosaic. Therefore this has to be implemented
 	 * by the provider.
 	 * @return
 	 *         a collection of {@link Time} objects.
@@ -845,11 +848,11 @@
 	public Collection<?> getTimes() {
 		return provider.getTimes();
 	}
-	
+
 	/**
 	 * Gets all the possible values of time for which the store has data
 	 * and intersects with an interval.
-	 * In raster this method has sense in a mosaic. Therefore this has to be implemented 
+	 * In raster this method has sense in a mosaic. Therefore this has to be implemented
 	 * by the provider.
 	 * @param interval
 	 *         the interval of time
@@ -859,13 +862,13 @@
 	public Collection<?> getTimes(Interval interval) {
 		return provider.getTimes(interval);
 	}
-	
+
 	public Image getImageLegend() {
 		if(provider != null)
 			return provider.getImageLegend();
 		return null;
 	}
-	
+
 	/**
 	 * Gets the list of geo points associated to this provider
 	 * @return
@@ -873,14 +876,14 @@
 	public GeoPointList getGeoPointList() {
 		return provider.getGeoPointList();
 	}
-	
+
 	/**
 	 * Sets the list of geo points associated to this provider
 	 */
 	public void setGeoPointList(GeoPointList geoPointList) {
 		provider.setGeoPointList(geoPointList);
 	}
-	
+
 	public Envelope getFullEnvelope() {
 		Rectangle2D e = getExtent().toRectangle2D();
 		try {
@@ -891,12 +894,12 @@
 			return null;
 		}
 	}
-	
+
 	public List<ROI> getRois(String epsg) throws ROIException {
 		IProjection proj = CRSFactory.getCRS(epsg);
 		return getRois(proj);
 	}
-	
+
 	public List<ROI> getRois(IProjection defaultProjection) throws ROIException {
 		if(rois == null) {
 			try {
@@ -908,7 +911,7 @@
 						proj = defaultProjection;
 					}
 					ROIReader reader = new VectorialROIsReader(
-							f.getPath(), 
+							f.getPath(),
 							getDataStore(),
 							proj,
 							getFullEnvelope());
@@ -925,15 +928,15 @@
 	public void setRois(List<ROI> rois) {
 		this.rois = rois;
 	}
-	
+
 	public void setROIsFiles(List<File> file) throws RmfSerializerException {
 		getDataStore().saveROIFileListToRmf(file);
 	}
-	
+
 	public List<File> getROIsFiles() throws RmfSerializerException {
 		return getDataStore().getROIFileListFromRmf();
 	}
-	
+
 	public void close() {
 		if(provider != null)
 			provider.close();
@@ -947,7 +950,7 @@
 		} catch (Throwable e) {
 		}
 	}
-	
+
 	protected void finalize() throws Throwable {
 		provider               = null;
 		storeBandList               = null;
@@ -958,11 +961,11 @@
 		}
 		super.finalize();
 	}
-	
+
 	//******************************
 	//Persistence
 	//******************************
-	
+
 	public static void registerPersistence() {
 		PersistenceManager manager = ToolsLocator.getPersistenceManager();
 		DynStruct definition = manager.getDefinition(PERSISTENT_NAME);
@@ -971,42 +974,42 @@
 					DefaultRasterStore.class,
 					PERSISTENT_NAME,
 					PERSISTENT_DESCRIPTION,
-					null, 
+					null,
 					null
 			);
-			
+
 			definition.addDynFieldObject("parameters")
 			.setClassOfValue(RasterDataParameters.class)
 			.setMandatory(true);
-			
+
 			definition.addDynFieldString("explorername")
 			.setMandatory(false);
-			
+
 			definition.addDynFieldObject("bandList")
 			.setClassOfValue(BandList.class)
 			.setMandatory(false);
-			
+
 			definition.addDynFieldObject("metadata")
 			.setClassOfValue(Metadata.class)
 			.setMandatory(false);
-			
+
 			definition.addDynFieldObject("render")
 			.setClassOfValue(Render.class)
 			.setMandatory(false);
 		}
 	}
-	
+
 	public void loadFromState(PersistentState state)
 			throws PersistenceException {
 		this.parameters = (RasterDataParameters)state.get("parameters");
-		
+
 		String explorerName = (String)state.get("explorername");
 		if(explorerName != null) {
 			if(initializePersistentParameters((RasterDataParameters)this.parameters, explorerName) == null) {
 				throw new PersistenceException();
 			}
 		}
-		
+
 		try {
 			DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
 			this.provider = (AbstractRasterProvider)dataManager.createProvider(this, this.parameters);
@@ -1015,18 +1018,18 @@
 		} catch (ProviderNotRegisteredException e) {
 			throw new PersistenceException(e);
 		}
-		
+
 		this.storeBandList = (BandListImpl)state.get("bandList");
 		if(parameters instanceof AbstractRasterFileDataParameters && !this.provider.isMultiFile()) {
 			//Esto solo es por si al cargar un proyecto se ha cambiado el fichero de sitio y el usuario
-			//lo introduce manualmente. En ese caso el bandList debe contener la misma ruta al fichero que el 
+			//lo introduce manualmente. En ese caso el bandList debe contener la misma ruta al fichero que el
 			//provider y no la que se grabó inicialmente
 			for (int i = 0; i < storeBandList.getBandCount(); i++) {
-				storeBandList.getBand(i).setFileName(provider.getURI());				
+				storeBandList.getBand(i).setFileName(provider.getURI().getPath());
 			}
 		}
 		this.metadata = (Metadata)state.get("metadata");
-		
+
 		DefaultRender render = (DefaultRender)state.get("render");
 		if(render == null)
 			throw new PersistenceException();
@@ -1036,16 +1039,16 @@
 		if(getRender().getRenderingTransparency() != null)
 			getRender().getRenderingTransparency().setNoData(getNoDataValue());
 	}
-	
+
 	public void saveToState(PersistentState state) throws PersistenceException {
-		state.set("parameters", provider.getDataParameters());	
+		state.set("parameters", provider.getDataParameters());
 		RasterDataParameters provParams = getInternalDataParameterFromState(provider.getDataParameters());
 		state.set("explorername", provParams.getDataStoreName());
 		state.set("bandList", storeBandList);
 		state.set("metadata", metadata);
 		state.set("render", getRender());
-	}	
-	
+	}
+
 	/**
 	 * Actions to initialize parameters before loaded more parts of the project
 	 * @param providerParams
@@ -1056,7 +1059,7 @@
 		try {
 			if(!(getInternalDataParameterFromState(providerParams) instanceof RemoteStoreParameters))
 				return providerParams;
-			
+
 			DataManager datamanager = DALLocator.getDataManager();
 			DataServerExplorerParameters explorerParams = null;
 			explorerParams = datamanager.createServerExplorerParameters(explorerName);
@@ -1065,20 +1068,20 @@
 			DataServerExplorer e = datamanager.openServerExplorer(explorerName, explorerParams);
 			if(e instanceof RasterDataServerExplorer) {
 				explorer = (RasterDataServerExplorer)e;
-				
+
 				explorerParams = explorer.getParameters();
 				explorerParams.setDynValue("host", providerParams.getURI());
-				
+
 				if(!explorer.isHostReachable()) {
 					return null;
 				}
-				
+
 				try {
 					explorer.connect(null);
 				} catch (ConnectException exc) {
 					return null;
 				}
-				
+
 				RasterDataParameters newParameters = getInternalDataParameterFromState(explorer.getStoredParameters());
 				newParameters.assignFields(getInternalDataParameterFromState(providerParams), explorer);
 				if(providerParams instanceof TileDataParameters)
@@ -1090,7 +1093,7 @@
 		}
 		return null;
 	}
-	
+
 	private RasterDataParameters getInternalDataParameterFromState(Object obj) {
 		if(obj instanceof TileDataParameters) {
 			return (RasterDataParameters)((TileDataParameters) obj).getDataParameters();
