public IPersonalDataCell ReadPersonalDataCell(object userId, string tableId, object rowId, string columnId) { if (userId is null) { throw new ArgumentNullException(nameof(userId)); } if (String.IsNullOrEmpty(tableId)) { throw new ArgumentException("Parameter tableId must not be null or empty", nameof(tableId)); } if (rowId is null) { throw new ArgumentNullException(nameof(rowId)); } if (String.IsNullOrEmpty(columnId)) { throw new ArgumentException("Parameter columnId must not be null or empty", nameof(columnId)); } lock (dataAccessLock) { CheckUserId(userId); CheckTableId(tableId); CheckColumnId(tableId, columnId); CheckRowId(tableId, rowId); object ownerId = dataProvider.GetOwnerForRowId(tableId, rowId); CheckAccessibility(PurposeType.HoldingAndReading, ownerId, tableId, rowId, columnId); IPersonalDataCell personalDataCell = dataProvider.ReadPersonalDataCell(tableId, columnId, rowId); if (personalDataCell.IsDefined) { ITableDefinition table = dataProvider.GetTable(tableId); IColumnDefinition column = dataProvider.GetColumn(tableId, columnId); string tableLogName = table.Name ?? table.ID; string columnLogName = column.Name ?? column.ID; WriteOwnerLog(ownerId, $"Your personal data has been read. We accessed your data in the the column \"{columnLogName}\" in the table \"{tableLogName}\""); } WriteUserLog(userId, $"Personal data cell of owner ID {ownerId} has been accessed: table {tableId}, column {columnId}, row {rowId.ToString()}"); return(personalDataCell); } }
public IPersonalDataCell ReadPersonalDataCell(object ownerId, string tableId, object rowId, string columnId) { if (ownerId is null) { throw new ArgumentNullException(nameof(ownerId)); } if (String.IsNullOrEmpty(tableId)) { throw new ArgumentException("Parameter tableId must not be null or empty", nameof(tableId)); } if (rowId is null) { throw new ArgumentNullException(nameof(rowId)); } if (String.IsNullOrEmpty(columnId)) { throw new ArgumentException("Parameter columnId must not be null or empty", nameof(columnId)); } lock (dataAccessLock) { CheckOwnerId(ownerId); CheckTableId(tableId); CheckColumnId(tableId, columnId); CheckRowId(tableId, rowId); object trueOwnerId = dataProvider.GetOwnerForRowId(tableId, rowId); if (!ownerId.Equals(trueOwnerId)) { throw new PersonalDataDBException($"The requested row does not belong to the owner in the parameter {nameof(ownerId)}"); } IPersonalDataCell personalDataCell = dataProvider.ReadPersonalDataCell(tableId, columnId, rowId); WriteUserLog(ownerId, $"You accessed your personal data in the table cell: table {tableId}, column {columnId}, row {rowId.ToString()}"); return(personalDataCell); } }