Skip to content

Commit 02188d7

Browse files
FINERACT-2623: Add permission handling for center notes
- Add CENTER enum value to NoteType - Add centerId field and withCenterId() method to CommandWrapperBuilder - Add CENTER case in NotesApiResource.getResourceDetails() - Enable separate permissions for Read, Create, Update, Delete center notes - Follows same permission pattern as existing GROUP notes
1 parent 3a6f805 commit 02188d7

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class CommandWrapperBuilder {
4141
private Long clientId;
4242
private Long loanId;
4343
private Long savingsId;
44+
private Long centerId;
4445
private String actionName;
4546
private String entityName;
4647
private Long entityId;
@@ -203,6 +204,11 @@ public CommandWrapperBuilder withClientId(final Long withClientId) {
203204
return this;
204205
}
205206

207+
public CommandWrapperBuilder withCenterId(final Long centerId) {
208+
this.centerId = centerId;
209+
return this;
210+
}
211+
206212
public CommandWrapperBuilder withGroupId(final Long withGroupId) {
207213
this.groupId = withGroupId;
208214
return this;

fineract-core/src/main/java/org/apache/fineract/portfolio/note/domain/NoteType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public enum NoteType {
2828
CLIENT(100, "noteType.client", "clients", "Client note"), //
2929
LOAN(200, "noteType.loan", "loans", "Loan note"), //
3030
LOAN_TRANSACTION(300, "noteType.loan.transaction", "loanTransactions", "Loan transaction note"), //
31+
CENTER(400, "noteType.center", "centers", "Center note"), //
3132
SAVING_ACCOUNT(500, "noteType.saving", "savings", " account note"), //
3233
GROUP(600, "noteType.group", "groups", "Group note"), //
3334
SHARE_ACCOUNT(700, "noteType.shares", "accounts/share", "Share account note"), //

fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class NotesApiResource {
6565
public static final String LOANTRANSACTIONNOTE = "LOANTRANSACTIONNOTE";
6666
public static final String SAVINGNOTE = "SAVINGNOTE";
6767
public static final String GROUPNOTE = "GROUPNOTE";
68+
public static final String CENTERNOTE = "CENTERNOTE";
6869
public static final String INVALIDNOTE = "INVALIDNOTE";
6970
private static final Set<String> NOTE_DATA_PARAMETERS = new HashSet<>(
7071
Arrays.asList("id", "resourceId", "clientId", "groupId", "loanId", "loanTransactionId", "depositAccountId", "savingAccountId",
@@ -228,7 +229,11 @@ private CommandWrapper getResourceDetails(final NoteType type, final Long resour
228229
resourceNameForPermissions = GROUPNOTE;
229230
resourceDetails.withGroupId(resourceId);
230231
}
231-
default -> resourceNameForPermissions = INVALIDNOTE;
232+
case CENTER -> {
233+
resourceNameForPermissions = CENTERNOTE;
234+
resourceDetails.withCenterId(resourceId);
235+
}
236+
default -> throw new NoteResourceNotSupportedException(type.name());
232237
}
233238
return resourceDetails.withEntityName(resourceNameForPermissions).build();
234239
}

0 commit comments

Comments
 (0)