Search in sources :

Example 1 with DBPAuthInfo

use of org.jkiss.dbeaver.model.connection.DBPAuthInfo in project dbeaver by dbeaver.

the class MavenRegistry method saveConfiguration.

public void saveConfiguration() {
    sortRepositories();
    try (OutputStream is = new FileOutputStream(getConfigurationFile())) {
        XMLBuilder xml = new XMLBuilder(is, GeneralUtils.UTF8_ENCODING);
        xml.setButify(true);
        try (final XMLBuilder.Element e1 = xml.startElement("maven")) {
            for (MavenRepository repository : repositories) {
                try (final XMLBuilder.Element e2 = xml.startElement("repository")) {
                    xml.addAttribute("id", repository.getId());
                    xml.addAttribute("order", repository.getOrder());
                    xml.addAttribute("enabled", repository.isEnabled());
                    if (repository.getType() != MavenRepository.RepositoryType.GLOBAL) {
                        xml.addAttribute("url", repository.getUrl());
                        xml.addAttribute("name", repository.getName());
                        if (!CommonUtils.isEmpty(repository.getDescription())) {
                            xml.addAttribute("description", repository.getDescription());
                        }
                        for (String scope : repository.getScopes()) {
                            try (final XMLBuilder.Element e3 = xml.startElement("scope")) {
                                xml.addAttribute("group", scope);
                            }
                        }
                        final DBPAuthInfo authInfo = repository.getAuthInfo();
                        if (!CommonUtils.isEmpty(authInfo.getUserName())) {
                            xml.addAttribute("auth-user", authInfo.getUserName());
                            if (!CommonUtils.isEmpty(authInfo.getUserPassword())) {
                                xml.addAttribute("auth-password", ENCRYPTOR.encrypt(authInfo.getUserPassword()));
                            }
                        }
                    }
                }
            }
        }
        xml.flush();
    } catch (Exception e) {
        log.error("Error saving Maven registry", e);
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) DBPAuthInfo(org.jkiss.dbeaver.model.connection.DBPAuthInfo) XMLBuilder(org.jkiss.utils.xml.XMLBuilder) IOException(java.io.IOException)

Example 2 with DBPAuthInfo

use of org.jkiss.dbeaver.model.connection.DBPAuthInfo in project dbeaver by serge-rider.

the class MavenRegistry method saveConfiguration.

public void saveConfiguration() {
    sortRepositories();
    try (OutputStream is = new FileOutputStream(getConfigurationFile())) {
        XMLBuilder xml = new XMLBuilder(is, GeneralUtils.UTF8_ENCODING);
        xml.setButify(true);
        try (final XMLBuilder.Element e1 = xml.startElement("maven")) {
            for (MavenRepository repository : repositories) {
                try (final XMLBuilder.Element e2 = xml.startElement("repository")) {
                    xml.addAttribute("id", repository.getId());
                    xml.addAttribute("order", repository.getOrder());
                    xml.addAttribute("enabled", repository.isEnabled());
                    if (repository.getType() != MavenRepository.RepositoryType.GLOBAL) {
                        xml.addAttribute("url", repository.getUrl());
                        xml.addAttribute("name", repository.getName());
                        if (!CommonUtils.isEmpty(repository.getDescription())) {
                            xml.addAttribute("description", repository.getDescription());
                        }
                        for (String scope : repository.getScopes()) {
                            try (final XMLBuilder.Element e3 = xml.startElement("scope")) {
                                xml.addAttribute("group", scope);
                            }
                        }
                        final DBPAuthInfo authInfo = repository.getAuthInfo();
                        if (!CommonUtils.isEmpty(authInfo.getUserName())) {
                            xml.addAttribute("auth-user", authInfo.getUserName());
                            if (!CommonUtils.isEmpty(authInfo.getUserPassword())) {
                                xml.addAttribute("auth-password", ENCRYPTOR.encrypt(authInfo.getUserPassword()));
                            }
                        }
                    }
                }
            }
        }
        xml.flush();
    } catch (Exception e) {
        log.error("Error saving Maven registry", e);
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) DBPAuthInfo(org.jkiss.dbeaver.model.connection.DBPAuthInfo) XMLBuilder(org.jkiss.utils.xml.XMLBuilder) IOException(java.io.IOException)

Aggregations

FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 DBPAuthInfo (org.jkiss.dbeaver.model.connection.DBPAuthInfo)2 XMLBuilder (org.jkiss.utils.xml.XMLBuilder)2