Search in sources :

Example 1 with GeoServerConnection

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

Example 2 with GeoServerConnection

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;
}
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 3 with GeoServerConnection

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

Example 4 with GeoServerConnection

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

Example 5 with GeoServerConnection

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) File(java.io.File) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection)

Aggregations

GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)50 Test (org.junit.Test)31 URL (java.net.URL)12 ArrayList (java.util.ArrayList)11 StyleWrapper (com.sldeditor.common.data.StyleWrapper)10 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)9 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)9 MalformedURLException (java.net.MalformedURLException)9 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)8 SLDData (com.sldeditor.common.data.SLDData)7 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)5 GeoServerOverallNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerOverallNode)5 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)5 GeoServerReadProgress (com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress)5 GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)5 HashMap (java.util.HashMap)5 List (java.util.List)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)4 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4