use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerConnectionManager method createGeoServerClient.
/**
* Creates the GeoServer client.
*
* @param progress the progress
* @param connection the connection
* @return the GeoServer client
*/
private GeoServerClientInterface createGeoServerClient(GeoServerReadProgress progress, GeoServerConnection connection) {
GeoServerClientInterface client = null;
try {
client = (GeoServerClientInterface) Class.forName(GeoServerConnectionManager.geoServerClientClass.getName()).newInstance();
client.initialise(progress, connection);
} catch (InstantiationException e) {
ConsoleManager.getInstance().exception(GeoServerInput.class, e);
} catch (IllegalAccessException e) {
ConsoleManager.getInstance().exception(GeoServerInput.class, e);
} catch (ClassNotFoundException e) {
ConsoleManager.getInstance().exception(GeoServerInput.class, e);
}
return client;
}
use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerInput method connectToGeoServer.
/**
* Connect to GeoServer.
*
* @param connection the connection
* @return true, if successful
*/
private boolean connectToGeoServer(GeoServerConnection connection) {
boolean isConnected = false;
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connection);
if (client != null) {
client.connect();
String url = "";
if (connection.getUrl() != null) {
url = connection.getUrl().toExternalForm();
}
if (client.isConnected()) {
String message = String.format("%s : %s (%s)", Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.connected"), connection.getConnectionName(), url);
ConsoleManager.getInstance().information(GeoServerConnectionTool.class, message);
client.retrieveData();
isConnected = true;
} else {
String errorMessage = String.format("%s : %s (%s)", Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.failedToConnect"), connection.getConnectionName(), url);
ConsoleManager.getInstance().error(GeoServerConnectionTool.class, errorMessage);
}
}
return isConnected;
}
use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerInput method getSLDContents.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#getSLDContents(com.sldeditor.extension.input.NodeInterface)
*/
@Override
public SelectedFiles getSLDContents(NodeInterface node) {
if (node instanceof GeoServerStyleNode) {
GeoServerStyleNode styleNode = (GeoServerStyleNode) node;
GeoServerConnection connectionData = styleNode.getConnectionData();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
if (client != null) {
String sldContent = client.getStyle(styleNode.getStyle());
SLDDataInterface sldData = new SLDData(styleNode.getStyle(), sldContent);
sldData.setConnectionData(connectionData);
sldData.setReadOnly(false);
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
sldDataList.add(sldData);
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
}
} else if (node instanceof GeoServerWorkspaceNode) {
GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) node;
GeoServerConnection connectionData = workspaceNode.getConnection();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
if (workspaceNode.isStyle()) {
Map<String, List<StyleWrapper>> styleMap = getStyleMap(connectionData);
if ((client != null) && (styleMap != null)) {
for (StyleWrapper style : styleMap.get(workspaceNode.getWorkspaceName())) {
String sldContent = client.getStyle(style);
SLDDataInterface sldData = new SLDData(style, sldContent);
sldData.setConnectionData(connectionData);
sldData.setReadOnly(false);
sldDataList.add(sldData);
}
}
}
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
} else if (node instanceof GeoServerStyleHeadingNode) {
GeoServerStyleHeadingNode styleHeadingNode = (GeoServerStyleHeadingNode) node;
GeoServerConnection connectionData = styleHeadingNode.getConnection();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
Map<String, List<StyleWrapper>> styleMap = getStyleMap(connectionData);
if ((client != null) && (styleMap != null)) {
for (String workspaceName : styleMap.keySet()) {
for (StyleWrapper style : styleMap.get(workspaceName)) {
String sldContent = client.getStyle(style);
SLDDataInterface sldData = new SLDData(style, sldContent);
sldData.setConnectionData(connectionData);
sldData.setReadOnly(false);
sldDataList.add(sldData);
}
}
}
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
} else if (node instanceof GeoServerNode) {
GeoServerNode geoServerNode = (GeoServerNode) node;
GeoServerConnection connectionData = geoServerNode.getConnection();
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
}
return null;
}
use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerInput method deleteConnections.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.geoserver.GeoServerConnectUpdateInterface#deleteConnections(java.util.List)
*/
@Override
public void deleteConnections(List<GeoServerConnection> connectionList) {
if (connectionList == null) {
return;
}
for (GeoServerConnection connection : connectionList) {
logger.debug("Deleting connection : " + connection.getConnectionName());
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connection);
if (client != null) {
disconnectFromGeoServer(client);
geoServerLayerMap.remove(connection);
geoServerStyleMap.remove(connection);
GeoServerConnectionManager.getInstance().removeConnection(connection);
progress.deleteConnection(connection);
}
}
updatePropertyFile();
progress.refreshNode(getRootGeoServerNode());
progress.setFolder(null, false);
}
use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerInput method updateConnectionDetails.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.geoserver.GeoServerConnectUpdateInterface#updateConnectionDetails(com.sldeditor.extension.input.geoserver.
* GeoServerConnection, com.sldeditor.extension.input.geoserver.GeoServerConnection)
*/
@Override
public void updateConnectionDetails(GeoServerConnection originalConnectionDetails, GeoServerConnection newConnectionDetails) {
if ((originalConnectionDetails == null) || (newConnectionDetails == null)) {
return;
}
logger.debug("Updating connection : " + newConnectionDetails.getConnectionName());
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(originalConnectionDetails);
if (client != null) {
disconnectFromGeoServer(client);
}
progress.updateConnection(originalConnectionDetails, newConnectionDetails);
if (toolMgr != null) {
toolMgr.refreshSelection();
}
updatePropertyFile();
}
Aggregations