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);
}
}
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();
}
}
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);
}
}
Aggregations