use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerInput method getDestinationText.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#getDestinationText(com.sldeditor.extension.input.NodeInterface)
*/
@Override
public String getDestinationText(NodeInterface destinationTreeNode) {
if (destinationTreeNode instanceof GeoServerWorkspaceNode) {
GeoServerWorkspaceNode destinationNode = (GeoServerWorkspaceNode) destinationTreeNode;
GeoServerConnection connection = destinationNode.getConnection();
return String.format("GeoServer %s / Workspace %s", connection.getConnectionName(), destinationNode.getWorkspaceName());
}
return "Unknown";
}
use of com.sldeditor.common.data.GeoServerConnection 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.common.data.GeoServerConnection 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.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerInput method disconnectFromGeoServer.
/**
* Disconnect from GeoServer.
*
* @param client the connection
*/
private void disconnectFromGeoServer(GeoServerClientInterface client) {
if (client != null) {
client.disconnect();
GeoServerConnection connection = client.getConnection();
if (connection != null) {
geoServerStyleMap.remove(connection);
geoServerLayerMap.remove(connection);
progress.disconnect(connection);
}
}
}
use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class FileSystemExtension method setArguments.
/*
* (non-Javadoc)
*
* @see com.sldeditor.batch.ExtensionInterface#setArguments(java.util.List)
*/
@Override
public String setArguments(List<String> extensionArgList) {
String acceptArgument = null;
if (extensionArgList != null) {
for (String arg : extensionArgList) {
logger.debug(arg);
String[] components = arg.split("=");
if (components.length == 2) {
String field = components[0];
String value = components[1];
if (field.compareToIgnoreCase(FOLDER_ARG) == 0) {
// Check to if the stored string is a folder,
// expecting it to be stored as an URL
File folder = new File(value);
if (folder.isDirectory()) {
// Folder was stored as an URL
if (folder.exists()) {
try {
FileSystemExtensionFactory.getFileSystemInput().setFolder(folder.toURI().toURL(), false);
acceptArgument = arg;
} catch (MalformedURLException e) {
ConsoleManager.getInstance().exception(this, e);
}
} else {
ConsoleManager.getInstance().error(this, Localisation.getField(getClass(), "FileSystemExtension.folderDoesNotExist") + value);
}
}
} else if (field.compareToIgnoreCase(GEOSERVER_ARG) == 0) {
// It wasn't a folder, check to see if it is a GeoServer connection
GeoServerConnection connectionData = GeoServerConnectionManager.getInstance().getConnection(value);
if (connectionData != null) {
FileSystemExtensionFactory.getGeoServerInput().setFolder(connectionData, true);
acceptArgument = arg;
} else {
// Don't recognise the string
ConsoleManager.getInstance().error(this, Localisation.getField(getClass(), "FileSystemExtension.geoServerDoesNotExist") + value);
}
} else {
// Don't recognise the string
ConsoleManager.getInstance().error(this, Localisation.getField(getClass(), "FileSystemExtension.unknownStartUp") + value);
}
}
}
treeItemSelected();
}
return acceptArgument;
}
Aggregations