remove unused code around permissions from older prototype.
This commit is contained in:
-28
@@ -1,14 +1,9 @@
|
||||
package org.mifosng.platform.user.domain;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosng.platform.infrastructure.EmailDetail;
|
||||
import org.mifosng.platform.infrastructure.PlatformEmailService;
|
||||
import org.mifosng.platform.infrastructure.PlatformPasswordEncoder;
|
||||
import org.mifosng.platform.infrastructure.RandomPasswordGenerator;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -16,12 +11,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
public class JpaUserDomainService implements UserDomainService {
|
||||
|
||||
@Autowired
|
||||
private UserPriviledgeDomainService userPriviledgeDomainService;
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@Autowired
|
||||
private AppUserRepository userRepository;
|
||||
|
||||
@@ -31,23 +20,6 @@ public class JpaUserDomainService implements UserDomainService {
|
||||
@Autowired
|
||||
private PlatformEmailService emailService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void createDefaultAdminUser(final Office office) {
|
||||
|
||||
this.userPriviledgeDomainService.createAllOrganisationRolesAndPermissions();
|
||||
|
||||
List<Role> organisationalRoles = this.roleRepository.findAll();
|
||||
Set<Role> allRoles = new HashSet<Role>(organisationalRoles);
|
||||
|
||||
String username = "admin";
|
||||
String password = "";
|
||||
|
||||
AppUser defaultAdministrator = AppUser.createNew(office, allRoles, username, "email?", "Organisation", "Administrator", password);
|
||||
|
||||
this.create(defaultAdministrator);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void create(final AppUser appUser) {
|
||||
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package org.mifosng.platform.user.domain;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class JpaUserPriviledgeDomainService implements UserPriviledgeDomainService {
|
||||
|
||||
@Autowired
|
||||
private PermissionRepository permissionRepository;
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void createAllOrganisationRolesAndPermissions() {
|
||||
|
||||
// 2. create out of the box application permissions and roles
|
||||
Permission viewUsersAndRolesPermission = new PermissionBuilder().viewUsersAndRoles().build();
|
||||
Permission createUserPermission = new PermissionBuilder().userCreation().build();
|
||||
Permission createRolePermission = new PermissionBuilder().roleCreation().build();
|
||||
Permission updateApplicationPermissionsPermission = new PermissionBuilder().updateApplicationPermissions().build();
|
||||
|
||||
Permission[] userAdminPermissions = new Permission[] {viewUsersAndRolesPermission, createUserPermission,
|
||||
createRolePermission, updateApplicationPermissionsPermission};
|
||||
|
||||
Permission viewOrganisationOfficesStaffAndProductsPermission = new PermissionBuilder().viewOrganisationsOfficesStaffAndProducts().build();
|
||||
Permission addOfficePermission = new PermissionBuilder().addOffice().build();
|
||||
Permission addStaffPermission = new PermissionBuilder().addStaff().build();
|
||||
Permission addLoanProductPermission = new PermissionBuilder().addLoanProduct().build();
|
||||
|
||||
Permission[] organisationAdminPermissions = new Permission[] {viewOrganisationOfficesStaffAndProductsPermission, addOfficePermission
|
||||
,addStaffPermission, addLoanProductPermission};
|
||||
|
||||
Permission viewLoanPortfolioPermission = new PermissionBuilder().viewLoanPortfolio().build();
|
||||
Permission addLoanPermission = new PermissionBuilder().addLoan().build();
|
||||
Permission addBackdatedLoanPermission = new PermissionBuilder().addBackdatedLoan().build();
|
||||
Permission approveLoanPermission = new PermissionBuilder().approveLoan().build();
|
||||
Permission approveLoanWithPastDatePermission = new PermissionBuilder().approveLoanInThePast().build();
|
||||
Permission rejectLoanPermission = new PermissionBuilder().rejectLoan().build();
|
||||
Permission rejectLoanWithPastDatePermission = new PermissionBuilder().rejectLoanInThePast().build();
|
||||
Permission withdrawLoanPermission = new PermissionBuilder().withdrawLoan().build();
|
||||
Permission withdrawLoanWithPastDatePermission = new PermissionBuilder().withdrawLoanInThePast().build();
|
||||
Permission undoLoanApprovalPermission = new PermissionBuilder().undoLoanApproval().build();
|
||||
|
||||
Permission disburseLoanPermission = new PermissionBuilder().disburseLoan().build();
|
||||
Permission disburseLoanWithPastDatePermission = new PermissionBuilder().disburseLoanInThePast().build();
|
||||
Permission undoLoanDisbursalPermission = new PermissionBuilder().undoLoanDisbursal().build();
|
||||
|
||||
Permission makeLoanRepaymentPermission = new PermissionBuilder().makeLoanRepayment().build();
|
||||
Permission makeLoanRepaymentWithPastDatePermission = new PermissionBuilder().makeLoanRepaymentInThePast().build();
|
||||
|
||||
// Permission writeoffLoanPermission = new PermissionBuilder().writeoffLoan().build();
|
||||
// Permission writeoffLoanWithPastDatePermission = new PermissionBuilder().writeoffLoanInThePast().build();
|
||||
|
||||
// Permission rescheduleLoanPermission = new PermissionBuilder().rescheduleLoan().build();
|
||||
// Permission rescheduleLoanWithPastDatePermission = new PermissionBuilder().rescheduleInThePast().build();
|
||||
|
||||
// MIFOS-2878 - support recovery of payments for written off loans.
|
||||
|
||||
// support interest reduction for early payments and interest increase for late payments
|
||||
|
||||
// how many MFIs allow clients to be in multiple groups (more than one)?
|
||||
|
||||
Permission[] fullLoanPortfolioPermissions = new Permission[] {viewLoanPortfolioPermission,
|
||||
addLoanPermission,
|
||||
addBackdatedLoanPermission,
|
||||
approveLoanPermission,
|
||||
approveLoanWithPastDatePermission,
|
||||
rejectLoanPermission,
|
||||
rejectLoanWithPastDatePermission,
|
||||
withdrawLoanPermission,
|
||||
withdrawLoanWithPastDatePermission,
|
||||
undoLoanApprovalPermission,
|
||||
disburseLoanPermission,
|
||||
disburseLoanWithPastDatePermission,
|
||||
undoLoanDisbursalPermission,
|
||||
makeLoanRepaymentPermission,
|
||||
makeLoanRepaymentWithPastDatePermission,
|
||||
// writeoffLoanPermission,
|
||||
// writeoffLoanWithPastDatePermission,
|
||||
// rescheduleLoanPermission
|
||||
// ,rescheduleLoanWithPastDatePermission
|
||||
};
|
||||
|
||||
Permission dataMigrationPermission = new PermissionBuilder()
|
||||
.dataMigration().build();
|
||||
|
||||
Permission[] migrationPermissions = new Permission[] { dataMigrationPermission };
|
||||
|
||||
this.permissionRepository.save(Arrays.asList(userAdminPermissions));
|
||||
this.permissionRepository.save(Arrays.asList(organisationAdminPermissions));
|
||||
this.permissionRepository.save(Arrays.asList(fullLoanPortfolioPermissions));
|
||||
this.permissionRepository.save(Arrays.asList(migrationPermissions));
|
||||
|
||||
// 2. roles
|
||||
String userAdminRoleDescription = "A user administrator can create new roles, assign and update roles assigned to users and create and deactivate users.";
|
||||
|
||||
Role userAdminRole = new Role("User Administrator", userAdminRoleDescription, Arrays.asList(userAdminPermissions));
|
||||
|
||||
String organisationAdminRoleDescription = "A organisation administrator can view, create and update organisation office hierarchy, staff and products.";
|
||||
Role organisatonAdminRole = new Role("Organisation Administrator", organisationAdminRoleDescription, Arrays.asList(organisationAdminPermissions));
|
||||
|
||||
String fullLoanPortfolioRoleDescription = "A loan portfolio user can view, create and update client, group and loan information.";
|
||||
Role loanPortfolioFullRole = new Role("Full Loan Portfolio", fullLoanPortfolioRoleDescription, Arrays.asList(fullLoanPortfolioPermissions));
|
||||
|
||||
this.roleRepository.save(Arrays.asList(userAdminRole, organisatonAdminRole, loanPortfolioFullRole));
|
||||
}
|
||||
}
|
||||
@@ -28,21 +28,13 @@ public class Permission extends AbstractPersistable<Long> {
|
||||
@Column(name = "default_description", nullable = false, length=500)
|
||||
private final String defaultDescription;
|
||||
|
||||
public Permission() {
|
||||
protected Permission() {
|
||||
this.grouping = null;
|
||||
this.orderInGrouping = null;
|
||||
this.code = null;
|
||||
this.defaultDescription = null;
|
||||
this.defaultName = null;
|
||||
}
|
||||
//TODO - This constructor probably not used in app (JPW)
|
||||
public Permission(final String code, final String defaultDescription, final String defaultName) {
|
||||
this.grouping = "";
|
||||
this.orderInGrouping = 0;
|
||||
this.code = code;
|
||||
this.defaultDescription = defaultDescription;
|
||||
this.defaultName = defaultName;
|
||||
}
|
||||
|
||||
public boolean hasCode(String checkCode) {
|
||||
return this.code.equalsIgnoreCase(checkCode);
|
||||
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
package org.mifosng.platform.user.domain;
|
||||
|
||||
public class PermissionBuilder {
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public Permission build() {
|
||||
return new Permission(this.code, this.description, this.name);
|
||||
}
|
||||
|
||||
public PermissionBuilder userCreation() {
|
||||
this.code = "CAN_CREATE_APPLICATION_USER_ROLE";
|
||||
this.name = "User Creation";
|
||||
this.description = "Allows an application user to create other users for the application.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder roleCreation() {
|
||||
this.code = "CAN_CREATE_APPLICATION_ROLE_ROLE";
|
||||
this.name = "Role Creation";
|
||||
this.description = "Allows an application user to create other application roles for assigning to users.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder viewUsersAndRoles() {
|
||||
this.code = "CAN_VIEW_USERS_AND_ROLES_ROLE";
|
||||
this.name = "View users and roles";
|
||||
this.description = "Allows an application user to view other application users and roles in their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder updateApplicationPermissions() {
|
||||
this.code = "CAN_UPDATE_APPLICATION_PERMISSION_NAMES_AND_DESCRIPTIONS_ROLE";
|
||||
this.name = "Update name and descriptions of application permissions";
|
||||
this.description = "Allows an application user to update the names and description of application permissions for their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder viewOrganisationsOfficesStaffAndProducts() {
|
||||
this.code = "CAN_VIEW_ORGANISATION_WIDE_VIEW_OF_OFFICES_STAFF_AND_PRODUCTS_ROLE";
|
||||
this.name = "View organisations offices, staff and products";
|
||||
this.description = "Allows an application user to view all offices, staff and products for their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder addOffice() {
|
||||
this.code = "CAN_ADD_OFFICE_ROLE";
|
||||
this.name = "Add offices";
|
||||
this.description = "Allows an application user add new offices for their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder addStaff() {
|
||||
this.code = "CAN_ADD_STAFF_ROLE";
|
||||
this.name = "Add staff";
|
||||
this.description = "Allows an application user add new staff members for their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder addLoanProduct() {
|
||||
this.code = "CAN_ADD_LOAN_PRODUCT_ROLE";
|
||||
this.name = "Add loan product";
|
||||
this.description = "Allows an application user add new loan products for their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder viewLoanPortfolio() {
|
||||
this.code = "CAN_VIEW_LOAN_PORTFOLIO_ROLE";
|
||||
this.name = "View client, group and loan information";
|
||||
this.description = "Allows an application user to view client, group and loan information for their organisation.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder addLoan() {
|
||||
this.code = "CAN_ADD_LOAN_ROLE";
|
||||
this.name = "Add loan.";
|
||||
this.description = "Allows an application user to add a loan.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder addBackdatedLoan() {
|
||||
this.code = "CAN_ADD_BACKDATED_LOAN_ROLE";
|
||||
this.name = "Add backdated loan.";
|
||||
this.description = "Allows an application user to add a loan where the submitted on date is in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder approveLoan() {
|
||||
this.code = "CAN_APPROVE_LOAN_ROLE";
|
||||
this.name = "Approve loan.";
|
||||
this.description = "Allows an application user to approve a loan.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder approveLoanInThePast() {
|
||||
this.code = "CAN_APPROVE_LOAN_IN_THE_PAST_ROLE";
|
||||
this.name = "Approve loan with date in past.";
|
||||
this.description = "Allows an application user to approve a loan with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder rejectLoan() {
|
||||
this.code = "CAN_REJECT_LOAN_ROLE";
|
||||
this.name = "Reject loan.";
|
||||
this.description = "Allows an application user to reject the loan application.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder rejectLoanInThePast() {
|
||||
this.code = "CAN_REJECT_LOAN_IN_THE_PAST_ROLE";
|
||||
this.name = "Reject loan with date in past.";
|
||||
this.description = "Allows an application user to reject the loan application with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder withdrawLoan() {
|
||||
this.code = "CAN_WITHDRAW_LOAN_ROLE";
|
||||
this.name = "Withdraw loan.";
|
||||
this.description = "Allows an application user to withdraw the loan application.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder withdrawLoanInThePast() {
|
||||
this.code = "CAN_WITHDRAW_LOAN_IN_THE_PAST_ROLE";
|
||||
this.name = "Withdraw loan with date in past.";
|
||||
this.description = "Allows an application user to withraw the loan application with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder undoLoanApproval() {
|
||||
this.code = "CAN_UNDO_LOAN_APPROVAL_ROLE";
|
||||
this.name = "Undo loan approval.";
|
||||
this.description = "Allows an application user to undo a loan approval.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder disburseLoan() {
|
||||
this.code = "CAN_DISBURSE_LOAN_ROLE";
|
||||
this.name = "Disburse loan.";
|
||||
this.description = "Allows an application user to disburse the loan.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder disburseLoanInThePast() {
|
||||
this.code = "CAN_DISBURSE_LOAN_IN_THE_PAST_ROLE";
|
||||
this.name = "Disburse loan with date in past.";
|
||||
this.description = "Allows an application user to disburse the loan with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder undoLoanDisbursal() {
|
||||
this.code = "CAN_UNDO_LOAN_DISBURSAL_ROLE";
|
||||
this.name = "Undo loan disbursal.";
|
||||
this.description = "Allows an application user to undo a loan disbursal (if no payments already made).";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder makeLoanRepayment() {
|
||||
this.code = "CAN_MAKE_LOAN_REPAYMENT_ROLE";
|
||||
this.name = "Make loan repayment.";
|
||||
this.description = "Allows an application user to make a repayment against a loan.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder makeLoanRepaymentInThePast() {
|
||||
this.code = "CAN_MAKE_LOAN_REPAYMENT_IN_THE_PAST_ROLE";
|
||||
this.name = "Make loan repayment with date in past.";
|
||||
this.description = "Allows an application user to disburse the loan with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder writeoffLoan() {
|
||||
this.code = "CAN_WRITEOFF_LOAN_ROLE";
|
||||
this.name = "Write off loan.";
|
||||
this.description = "Allows an application user to write off the loan application.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder writeoffLoanInThePast() {
|
||||
this.code = "CAN_WRITEOFF_LOAN_IN_THE_PAST_ROLE";
|
||||
this.name = "Write off loan with date in past.";
|
||||
this.description = "Allows an application user to write off the loan application with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder rescheduleLoan() {
|
||||
this.code = "CAN_RESCHEDULE_LOAN_ROLE";
|
||||
this.name = "Reschedule loan.";
|
||||
this.description = "Allows an application user to reschedule the loan application.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder rescheduleInThePast() {
|
||||
this.code = "CAN_RESCHEDULE_LOAN_IN_THE_PAST_ROLE";
|
||||
this.name = "Reschedule loan with date in past.";
|
||||
this.description = "Allows an application user to reschedule the loan application with a date in the past.";
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermissionBuilder dataMigration() {
|
||||
this.code = "CAN_MIGRATE_DATA_ROLE";
|
||||
this.name = "Upload client, group and loan data onto application in bulk";
|
||||
this.description = "Allows an application user to upload client, group and loan information in bulk for their organisation.";
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
package org.mifosng.platform.user.domain;
|
||||
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
|
||||
public interface UserDomainService {
|
||||
|
||||
void createDefaultAdminUser(Office office);
|
||||
|
||||
void create(AppUser appUser);
|
||||
}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package org.mifosng.platform.user.domain;
|
||||
|
||||
public interface UserPriviledgeDomainService {
|
||||
|
||||
void createAllOrganisationRolesAndPermissions();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user