MIFOSX-749, MIFSOX-750: client search using search term and office hierarchy scoping were no longer working.
This commit is contained in:
+2
@@ -12,4 +12,6 @@ public interface PlatformSecurityContext {
|
|||||||
AppUser authenticatedUser();
|
AppUser authenticatedUser();
|
||||||
|
|
||||||
void validateAccessRights(String resourceOfficeHierarchy);
|
void validateAccessRights(String resourceOfficeHierarchy);
|
||||||
|
|
||||||
|
String officeHierarcy();
|
||||||
}
|
}
|
||||||
+5
@@ -46,4 +46,9 @@ public class SpringSecurityPlatformSecurityContext implements PlatformSecurityCo
|
|||||||
"The user doesn't have enough permissions to access the resource."); }
|
"The user doesn't have enough permissions to access the resource."); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String officeHierarcy() {
|
||||||
|
return authenticatedUser().getOffice().getHierarchy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-7
@@ -93,14 +93,18 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
@Override
|
@Override
|
||||||
public Page<ClientData> retrieveAll(final SearchParameters searchParameters) {
|
public Page<ClientData> retrieveAll(final SearchParameters searchParameters) {
|
||||||
|
|
||||||
final AppUser currentUser = this.context.authenticatedUser();
|
final String hierarchy = this.context.officeHierarcy();
|
||||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
String hierarchySearchString = hierarchy + "%";
|
||||||
final String hierarchySearchString = hierarchy + "%";
|
|
||||||
|
if (searchParameters.isScopedByOfficeHierarchy()) {
|
||||||
|
this.context.validateAccessRights(searchParameters.getHierarchy());
|
||||||
|
hierarchySearchString = searchParameters.getHierarchy();
|
||||||
|
}
|
||||||
|
|
||||||
final StringBuilder sqlBuilder = new StringBuilder(200);
|
final StringBuilder sqlBuilder = new StringBuilder(200);
|
||||||
sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
|
sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
|
||||||
sqlBuilder.append(this.clientMapper.schema());
|
sqlBuilder.append(this.clientMapper.schema());
|
||||||
sqlBuilder.append(" where o.hierarchy like ? or transferToOffice.hierarchy like ?");
|
sqlBuilder.append(" where (o.hierarchy like ? or transferToOffice.hierarchy like ?) ");
|
||||||
|
|
||||||
final String extraCriteria = buildSqlStringFromClientCriteria(searchParameters);
|
final String extraCriteria = buildSqlStringFromClientCriteria(searchParameters);
|
||||||
|
|
||||||
@@ -136,7 +140,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
final String displayName = searchParameters.getName();
|
final String displayName = searchParameters.getName();
|
||||||
final String firstname = searchParameters.getFirstname();
|
final String firstname = searchParameters.getFirstname();
|
||||||
final String lastname = searchParameters.getLastname();
|
final String lastname = searchParameters.getLastname();
|
||||||
final String hierarchy = searchParameters.getHierarchy();
|
|
||||||
|
|
||||||
String extraCriteria = "";
|
String extraCriteria = "";
|
||||||
if (sqlSearch != null) {
|
if (sqlSearch != null) {
|
||||||
@@ -166,8 +169,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
extraCriteria += " and lastname like " + ApiParameterHelper.sqlEncodeString(lastname);
|
extraCriteria += " and lastname like " + ApiParameterHelper.sqlEncodeString(lastname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hierarchy != null) {
|
if (searchParameters.isScopedByOfficeHierarchy()) {
|
||||||
extraCriteria += " and o.hierarchy like " + ApiParameterHelper.sqlEncodeString(hierarchy + "%");
|
extraCriteria += " and o.hierarchy like " + ApiParameterHelper.sqlEncodeString(searchParameters.getHierarchy() + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||||
|
|||||||
+12
-8
@@ -112,6 +112,18 @@ public final class SearchParameters {
|
|||||||
return this.officeId != null && this.officeId != 0;
|
return this.officeId != null && this.officeId != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLimited() {
|
||||||
|
return this.limit != null && this.limit.intValue() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOffset() {
|
||||||
|
return this.offset != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isScopedByOfficeHierarchy() {
|
||||||
|
return StringUtils.isNotBlank(this.hierarchy);
|
||||||
|
}
|
||||||
|
|
||||||
public String getSqlSearch() {
|
public String getSqlSearch() {
|
||||||
return this.sqlSearch;
|
return this.sqlSearch;
|
||||||
}
|
}
|
||||||
@@ -155,12 +167,4 @@ public final class SearchParameters {
|
|||||||
public String getSortOrder() {
|
public String getSortOrder() {
|
||||||
return this.sortOrder;
|
return this.sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLimited() {
|
|
||||||
return this.limit != null && this.limit.intValue() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOffset() {
|
|
||||||
return this.offset != null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user