Search in sources :

Example 1 with FolderConnectionRegistry

use of com.revolsys.io.file.FolderConnectionRegistry in project com.revolsys.open by revolsys.

the class ProjectFrame method setConnectionRegistries.

private void setConnectionRegistries() {
    final String connectionRegistryName = this.project.getConnectionRegistryName();
    final RecordStoreConnectionManager recordStoreConnectionManager = RecordStoreConnectionManager.get();
    recordStoreConnectionManager.removeConnectionRegistry(connectionRegistryName);
    final RecordStoreConnectionRegistry recordStores = this.project.getRecordStores();
    recordStoreConnectionManager.addConnectionRegistry(recordStores);
    final FileConnectionManager fileConnectionManager = FileConnectionManager.get();
    fileConnectionManager.removeConnectionRegistry(connectionRegistryName);
    final FolderConnectionRegistry folderConnections = this.project.getFolderConnections();
    fileConnectionManager.addConnectionRegistry(folderConnections);
    final WebServiceConnectionManager webServiceConnectionManager = WebServiceConnectionManager.get();
    webServiceConnectionManager.removeConnectionRegistry(connectionRegistryName);
    final WebServiceConnectionRegistry webServices = this.project.getWebServices();
    webServiceConnectionManager.addConnectionRegistry(webServices);
}
Also used : RecordStoreConnectionManager(com.revolsys.record.io.RecordStoreConnectionManager) FolderConnectionRegistry(com.revolsys.io.file.FolderConnectionRegistry) FileConnectionManager(com.revolsys.io.file.FileConnectionManager) WebServiceConnectionManager(com.revolsys.webservice.WebServiceConnectionManager) WebServiceConnectionRegistry(com.revolsys.webservice.WebServiceConnectionRegistry) RecordStoreConnectionRegistry(com.revolsys.record.io.RecordStoreConnectionRegistry)

Example 2 with FolderConnectionRegistry

use of com.revolsys.io.file.FolderConnectionRegistry in project com.revolsys.open by revolsys.

the class FileUtil method getFile.

public static File getFile(URI uri) {
    final String scheme = uri.getScheme();
    if ("folderconnection".equalsIgnoreCase(scheme)) {
        final String authority = uri.getAuthority();
        final String connectionName = UrlUtil.percentDecode(authority);
        final String path = uri.getPath();
        File file = null;
        for (final FolderConnectionRegistry registry : FileConnectionManager.get().getConnectionRegistries()) {
            final FolderConnection connection = registry.getConnection(connectionName);
            if (connection != null) {
                final File directory = connection.getFile();
                file = new File(directory, path);
                if (file.exists()) {
                    return getFile(file);
                }
            }
        }
        return file;
    } else if ("file".equalsIgnoreCase(scheme)) {
        try {
            uri = new URI(scheme, uri.getPath(), null);
        } catch (final URISyntaxException e) {
        }
        return getFile(new File(uri));
    } else {
        throw new IllegalArgumentException("file URL expected: " + uri);
    }
}
Also used : FolderConnectionRegistry(com.revolsys.io.file.FolderConnectionRegistry) FolderConnection(com.revolsys.io.file.FolderConnection) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URI(java.net.URI)

Example 3 with FolderConnectionRegistry

use of com.revolsys.io.file.FolderConnectionRegistry in project com.revolsys.open by revolsys.

the class Project method readProject.

public void readProject(final Project rootProject, final Resource resource) {
    this.resource = resource;
    if (this.resource.exists()) {
        String name;
        try (final BaseCloseable booleanValueCloseable = eventsDisabled()) {
            final RecordStoreConnectionRegistry oldRecordStoreConnections = RecordStoreConnectionRegistry.getForThread();
            try {
                final boolean readOnly = isReadOnly();
                final Resource folderConnectionsDirectory = this.resource.newChildResource("Folder Connections");
                this.folderConnections.clear(folderConnectionsDirectory, readOnly);
                final Resource recordStoresDirectory = this.resource.newChildResource("Record Stores");
                this.recordStores.clear(recordStoresDirectory, readOnly);
                final Resource webServicesDirectory = this.resource.newChildResource("Web Services");
                this.webServices.clear(webServicesDirectory, readOnly);
                if (rootProject == null) {
                    RecordStoreConnectionRegistry.setForThread(this.recordStores);
                } else {
                    final WebServiceConnectionRegistry rootWebServices = rootProject.getWebServices();
                    importConnections("Web Service", this, this.webServices, rootWebServices);
                    final RecordStoreConnectionRegistry rootRecordStores = rootProject.getRecordStores();
                    rootProject.importConnections("Record Store", this, this.recordStores, rootRecordStores);
                    final FolderConnectionRegistry rootFolderConnections = rootProject.getFolderConnections();
                    rootProject.importConnections("Folder Connection", this, this.folderConnections, rootFolderConnections);
                }
                final Resource layersDir = this.resource.newChildResource("Layers");
                final boolean hasLayers = layersDir.exists();
                if (hasLayers) {
                    readProperties(layersDir);
                }
                if (hasLayers) {
                    readLayers(rootProject, layersDir);
                }
                readBaseMapsLayers(rootProject, this.resource);
            } finally {
                RecordStoreConnectionRegistry.setForThread(oldRecordStoreConnections);
            }
            name = getName();
            setName(null);
        }
        setName(name);
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) FolderConnectionRegistry(com.revolsys.io.file.FolderConnectionRegistry) WebServiceConnectionRegistry(com.revolsys.webservice.WebServiceConnectionRegistry) PathResource(com.revolsys.spring.resource.PathResource) Resource(com.revolsys.spring.resource.Resource) RecordStoreConnectionRegistry(com.revolsys.record.io.RecordStoreConnectionRegistry)

Example 4 with FolderConnectionRegistry

use of com.revolsys.io.file.FolderConnectionRegistry in project com.revolsys.open by revolsys.

the class PathTreeNode method actionAddFolderConnection.

private void actionAddFolderConnection() {
    if (isDirectory()) {
        final Path path = getPath();
        final String fileName = getName();
        final ValueField panel = new ValueField();
        panel.setTitle("Add Folder Connection");
        Borders.titled(panel, "Folder Connection");
        SwingUtil.addLabel(panel, "Folder");
        final JLabel fileLabel = new JLabel(path.toString());
        panel.add(fileLabel);
        SwingUtil.addLabel(panel, "Name");
        final TextField nameField = new TextField(20);
        panel.add(nameField);
        nameField.setText(fileName);
        SwingUtil.addLabel(panel, "Folder Connections");
        final List<FolderConnectionRegistry> registries = new ArrayList<>();
        for (final FolderConnectionRegistry registry : FileConnectionManager.get().getVisibleConnectionRegistries()) {
            if (!registry.isReadOnly()) {
                registries.add(registry);
            }
        }
        final ComboBox<FolderConnectionRegistry> registryField = ComboBox.newComboBox("registry", new Vector<>(registries));
        panel.add(registryField);
        GroupLayouts.makeColumns(panel, 2, true);
        panel.showDialog();
        if (panel.isSaved()) {
            final FolderConnectionRegistry registry = registryField.getSelectedItem();
            String connectionName = nameField.getText();
            if (!Property.hasValue(connectionName)) {
                connectionName = fileName;
            }
            registry.addConnection(connectionName, path);
        }
    }
}
Also used : Path(java.nio.file.Path) FolderConnectionRegistry(com.revolsys.io.file.FolderConnectionRegistry) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) TextField(com.revolsys.swing.field.TextField) ValueField(com.revolsys.swing.component.ValueField)

Aggregations

FolderConnectionRegistry (com.revolsys.io.file.FolderConnectionRegistry)4 RecordStoreConnectionRegistry (com.revolsys.record.io.RecordStoreConnectionRegistry)2 WebServiceConnectionRegistry (com.revolsys.webservice.WebServiceConnectionRegistry)2 BaseCloseable (com.revolsys.io.BaseCloseable)1 FileConnectionManager (com.revolsys.io.file.FileConnectionManager)1 FolderConnection (com.revolsys.io.file.FolderConnection)1 RecordStoreConnectionManager (com.revolsys.record.io.RecordStoreConnectionManager)1 PathResource (com.revolsys.spring.resource.PathResource)1 Resource (com.revolsys.spring.resource.Resource)1 ValueField (com.revolsys.swing.component.ValueField)1 TextField (com.revolsys.swing.field.TextField)1 WebServiceConnectionManager (com.revolsys.webservice.WebServiceConnectionManager)1 File (java.io.File)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 JLabel (javax.swing.JLabel)1