Search in sources :

Example 1 with GeoServerClientInterface

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;
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput)

Example 2 with GeoServerClientInterface

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;
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerConnectionTool(com.sldeditor.tool.geoserverconnection.GeoServerConnectionTool)

Example 3 with GeoServerClientInterface

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;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) GeoServerStyleNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode) GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerStyleHeadingNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with GeoServerClientInterface

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);
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection)

Example 5 with GeoServerClientInterface

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();
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)

Aggregations

GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)10 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)3 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 NodeInterface (com.sldeditor.common.NodeInterface)1 GeoServerConnectionManagerInterface (com.sldeditor.common.connection.GeoServerConnectionManagerInterface)1 SLDData (com.sldeditor.common.data.SLDData)1 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)1 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)1 VersionData (com.sldeditor.common.vendoroption.VersionData)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 GeoServerStyleHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode)1