Skip to content

Commit

Permalink
fix: Add dart docs for the enrollment_manager.dart and remove comment…
Browse files Browse the repository at this point in the history
…ed code in enroll_verb_handler.dart
  • Loading branch information
sitaram-kalluri committed Sep 24, 2024
1 parent 7f9ff68 commit a0fe5a7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,35 @@ import 'package:at_secondary/src/server/at_secondary_impl.dart';
import 'package:at_secondary/src/utils/secondary_util.dart';
import 'package:at_utils/at_logger.dart';

/// Manages enrollment data in the secondary server.
///
/// This class provides methods to retrieve and store enrollment data
/// associated with a given enrollment ID. It interacts with the
/// SecondaryKeyStore to persist and retrieve enrollment information.
class EnrollmentManager {
final SecondaryKeyStore _keyStore;

final logger = AtSignLogger('AtSecondaryServer');

/// Creates an instance of [EnrollmentManager].
///
/// The [keyStore] is required to interact with the persistence layer.
EnrollmentManager(this._keyStore);

/// Retrieves the enrollment data for a given [enrollmentId].
///
/// This method constructs an enrollment key, fetches the corresponding
/// data from the key store, and returns it as an [EnrollDataStoreValue].
/// If the key is not found, a [KeyNotFoundException] is thrown.
///
/// If the retrieved enrollment data is no longer active, the status
/// will be set to `expired`.
///
/// Returns:
/// An [EnrollDataStoreValue] containing the enrollment details.
///
/// Throws:
/// [KeyNotFoundException] if the enrollment key does not exist.
Future<EnrollDataStoreValue> get(String enrollmentId) async {
String enrollmentKey = buildEnrollmentKey(enrollmentId);
try {
Expand All @@ -33,10 +55,26 @@ class EnrollmentManager {
}
}

/// Constructs the enrollment key based on the provided [enrollmentId].
///
/// The key format combines the [enrollmentId], a new enrollment key pattern,
/// and the current AtSign.
///
/// Returns:
/// A [String] representing the enrollment key.
String buildEnrollmentKey(String enrollmentId) {
return '$enrollmentId.$newEnrollmentKeyPattern.$enrollManageNamespace${AtSecondaryServerImpl.getInstance().currentAtSign}';
}

/// Stores the enrollment data associated with the given [enrollmentId].
///
/// This method constructs an enrollment key and saves the provided [AtData]
/// to the key store. The skipCommit is set to true, to prevent the enrollment
/// data being synced to the client(s).
///
/// Parameters:
/// - [enrollmentId]: The ID associated with the enrollment.
/// - [atData]: The [AtData] object to be stored.
Future<void> put(String enrollmentId, AtData atData) async {
String enrollmentKey = buildEnrollmentKey(enrollmentId);
await _keyStore.put(enrollmentKey, atData, skipCommit: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class EnrollVerbHandler extends AbstractVerbHandler {
..metaData = (AtMetaData()..ttl = enrollmentExpiryInMills);
}
logger.finer('enrollData: $enrollData');
//await keyStore.put('$key$currentAtSign', enrollData, skipCommit: true);
await AtSecondaryServerImpl.getInstance()
.enrollmentManager
.put(newEnrollmentId, enrollData);
Expand Down

0 comments on commit a0fe5a7

Please sign in to comment.