Search in sources :

Example 6 with DBPDataSourcePermission

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

the class DataSourceProviderRegistry method saveConnectionTypes.

@Override
public void saveConnectionTypes() {
    File ctConfig = DBWorkbench.getPlatform().getConfigurationFile(RegistryConstants.CONNECTION_TYPES_FILE_NAME);
    try {
        OutputStream os = new FileOutputStream(ctConfig);
        XMLBuilder xml = new XMLBuilder(os, GeneralUtils.UTF8_ENCODING);
        xml.setButify(true);
        xml.startElement(RegistryConstants.TAG_TYPES);
        for (DBPConnectionType connectionType : connectionTypes.values()) {
            xml.startElement(RegistryConstants.TAG_TYPE);
            xml.addAttribute(RegistryConstants.ATTR_ID, connectionType.getId());
            xml.addAttribute(RegistryConstants.ATTR_NAME, CommonUtils.toString(connectionType.getName()));
            xml.addAttribute(RegistryConstants.ATTR_COLOR, connectionType.getColor());
            xml.addAttribute(RegistryConstants.ATTR_DESCRIPTION, CommonUtils.toString(connectionType.getDescription()));
            xml.addAttribute(RegistryConstants.ATTR_AUTOCOMMIT, connectionType.isAutocommit());
            xml.addAttribute(RegistryConstants.ATTR_CONFIRM_EXECUTE, connectionType.isConfirmExecute());
            xml.addAttribute(RegistryConstants.ATTR_CONFIRM_DATA_CHANGE, connectionType.isConfirmDataChange());
            List<DBPDataSourcePermission> modifyPermission = connectionType.getModifyPermission();
            if (modifyPermission != null) {
                xml.addAttribute("modifyPermission", modifyPermission.stream().map(DBPDataSourcePermission::name).collect(Collectors.joining(",")));
            }
            xml.endElement();
        }
        xml.endElement();
        xml.flush();
        os.close();
    } catch (Exception ex) {
        log.warn("Error saving drivers", ex);
    }
}
Also used : DBPDataSourcePermission(org.jkiss.dbeaver.model.DBPDataSourcePermission) XMLBuilder(org.jkiss.utils.xml.XMLBuilder) XMLException(org.jkiss.utils.xml.XMLException)

Example 7 with DBPDataSourcePermission

use of org.jkiss.dbeaver.model.DBPDataSourcePermission in project dbeaver by dbeaver.

the class DataSourceSerializerModern method serializeModifyPermissions.

private void serializeModifyPermissions(@NotNull JsonWriter json, DBPDataSourcePermissionOwner permissionOwner) throws IOException {
    List<DBPDataSourcePermission> permissions = permissionOwner.getModifyPermission();
    if (!CommonUtils.isEmpty(permissions)) {
        json.name("security");
        json.beginObject();
        List<String> permIds = new ArrayList<>(permissions.size());
        for (DBPDataSourcePermission perm : permissions) permIds.add(perm.getId());
        JSONUtils.serializeStringList(json, "permission-restrictions", permIds);
        json.endObject();
    }
}
Also used : DBPDataSourcePermission(org.jkiss.dbeaver.model.DBPDataSourcePermission)

Example 8 with DBPDataSourcePermission

use of org.jkiss.dbeaver.model.DBPDataSourcePermission in project dbeaver by dbeaver.

the class DataSourceProviderRegistry method saveConnectionTypes.

@Override
public void saveConnectionTypes() {
    File ctConfig = DBWorkbench.getPlatform().getConfigurationFile(RegistryConstants.CONNECTION_TYPES_FILE_NAME);
    try {
        OutputStream os = new FileOutputStream(ctConfig);
        XMLBuilder xml = new XMLBuilder(os, GeneralUtils.UTF8_ENCODING);
        xml.setButify(true);
        xml.startElement(RegistryConstants.TAG_TYPES);
        for (DBPConnectionType connectionType : connectionTypes.values()) {
            xml.startElement(RegistryConstants.TAG_TYPE);
            xml.addAttribute(RegistryConstants.ATTR_ID, connectionType.getId());
            xml.addAttribute(RegistryConstants.ATTR_NAME, CommonUtils.toString(connectionType.getName()));
            xml.addAttribute(RegistryConstants.ATTR_COLOR, connectionType.getColor());
            xml.addAttribute(RegistryConstants.ATTR_DESCRIPTION, CommonUtils.toString(connectionType.getDescription()));
            xml.addAttribute(RegistryConstants.ATTR_AUTOCOMMIT, connectionType.isAutocommit());
            xml.addAttribute(RegistryConstants.ATTR_CONFIRM_EXECUTE, connectionType.isConfirmExecute());
            xml.addAttribute(RegistryConstants.ATTR_CONFIRM_DATA_CHANGE, connectionType.isConfirmDataChange());
            List<DBPDataSourcePermission> modifyPermission = connectionType.getModifyPermission();
            if (modifyPermission != null) {
                xml.addAttribute("modifyPermission", modifyPermission.stream().map(DBPDataSourcePermission::name).collect(Collectors.joining(",")));
            }
            xml.endElement();
        }
        xml.endElement();
        xml.flush();
        os.close();
    } catch (Exception ex) {
        log.warn("Error saving drivers", ex);
    }
}
Also used : DBPDataSourcePermission(org.jkiss.dbeaver.model.DBPDataSourcePermission) XMLBuilder(org.jkiss.utils.xml.XMLBuilder) XMLException(org.jkiss.utils.xml.XMLException)

Aggregations

DBPDataSourcePermission (org.jkiss.dbeaver.model.DBPDataSourcePermission)8 Button (org.eclipse.swt.widgets.Button)4 ArrayList (java.util.ArrayList)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 XMLBuilder (org.jkiss.utils.xml.XMLBuilder)2 XMLException (org.jkiss.utils.xml.XMLException)2