use of org.geotools.metadata.iso.citation.OnLineResourceImpl in project sldeditor by robward-scisys.
the class UpdateGraphicalSymbol method processGraphicalSymbol.
/*
* (non-Javadoc)
*
* @see com.sldeditor.common.data.ProcessGraphicSymbolInterface#processGraphicalSymbol(java.net.URL, java.util.List, java.util.List)
*/
@Override
public void processGraphicalSymbol(URL resourceLocator, List<GraphicalSymbol> graphicalSymbolList, List<String> externalImageList) {
for (GraphicalSymbol symbol : graphicalSymbolList) {
if (symbol instanceof ExternalGraphic) {
ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) symbol;
OnLineResourceImpl onlineResource = (OnLineResourceImpl) externalGraphic.getOnlineResource();
String currentValue = null;
URL currentValueURL = null;
try {
currentValueURL = onlineResource.getLinkage().toURL();
currentValue = currentValueURL.toExternalForm();
} catch (MalformedURLException e) {
ConsoleManager.getInstance().exception(SLDExternalImages.class, e);
}
if ((resourceLocator == null) || RelativePath.hasHost(currentValueURL)) {
// Just report back the external image
URI uri = null;
try {
uri = new URI(currentValue);
externalImageList.add(uri.toASCIIString());
} catch (URISyntaxException e) {
ConsoleManager.getInstance().exception(SLDExternalImages.class, e);
}
} else {
try {
File file = new File(currentValueURL.getFile());
File folder = new File(resourceLocator.getFile());
currentValue = RelativePath.getRelativePath(file, folder);
// If the backslashes are not converted to forward slashes
// creating the URI does not work
currentValue = currentValue.replace('\\', '/');
OnLineResourceImpl updatedOnlineResource = new OnLineResourceImpl();
URI uri = new URI(currentValue);
updatedOnlineResource.setLinkage(uri);
externalGraphic.setOnlineResource(updatedOnlineResource);
externalGraphic.setURI(uri.toASCIIString());
externalImageList.add(uri.toASCIIString());
} catch (URISyntaxException e) {
ConsoleManager.getInstance().exception(SLDExternalImages.class, e);
}
}
}
}
}
Aggregations