Using sysadmin to list item in moderation. Filtering own item
This commit is contained in:
parent
a2c2c0044e
commit
88bea376f3
|
@ -1065,44 +1065,44 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
|
||||
CMItemStatus cmItemStatus = getRequestedCMItemStatus();
|
||||
|
||||
this.apiKey = CKANUtility.getSysAdminAPI();
|
||||
|
||||
if(!ckanUser.isCatalogueModerator()) {
|
||||
q = String.format("%s AND %s:%s", q, AUTHOR_EMAIL_KEY, ckanUser.getEMail());
|
||||
parameters.put(GCatConstants.Q_KEY, q);
|
||||
|
||||
switch (ckanUser.getRole()) {
|
||||
case ADMIN:
|
||||
case MANAGER:
|
||||
break;
|
||||
|
||||
case EDITOR:
|
||||
q = String.format("%s AND %s:%s", q, AUTHOR_EMAIL_KEY, ckanUser.getEMail());
|
||||
parameters.put(GCatConstants.Q_KEY, q);
|
||||
break;
|
||||
|
||||
case MEMBER:
|
||||
if(cmItemStatus!=null && cmItemStatus!=CMItemStatus.APPROVED) {
|
||||
throw new ForbiddenException("You are only authorized to list " + CMItemStatus.APPROVED.getValue() + " items");
|
||||
}
|
||||
cmItemStatus = CMItemStatus.APPROVED;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(cmItemStatus!=null) {
|
||||
stringBuffer.append(cmItemStatus.getValue());
|
||||
if(cmItemStatus == CMItemStatus.APPROVED) {
|
||||
stringBuffer.append(" OR (*:* -");
|
||||
stringBuffer.append(CM_STATUS_QUERY_FILTER_KEY);
|
||||
stringBuffer.append(":[* TO *])");
|
||||
}
|
||||
stringBuffer.append(")");
|
||||
q = String.format("%s AND %s", q, stringBuffer.toString());
|
||||
parameters.put(GCatConstants.Q_KEY, q);
|
||||
if(cmItemStatus==null) {
|
||||
cmItemStatus = CMItemStatus.APPROVED;
|
||||
}
|
||||
|
||||
stringBuffer.append(cmItemStatus.getValue());
|
||||
if(cmItemStatus == CMItemStatus.APPROVED) {
|
||||
stringBuffer.append(" OR (*:* -");
|
||||
stringBuffer.append(CM_STATUS_QUERY_FILTER_KEY);
|
||||
stringBuffer.append(":[* TO *])");
|
||||
}
|
||||
stringBuffer.append(")");
|
||||
q = String.format("%s AND %s", q, stringBuffer.toString());
|
||||
parameters.put(GCatConstants.Q_KEY, q);
|
||||
|
||||
|
||||
parameters.put(INCLUDE_PRIVATE_KEY, String.valueOf(true));
|
||||
}else{
|
||||
if(ckanUser.getRole().ordinal()>=Role.ADMIN.ordinal()) {
|
||||
|
|
Loading…
Reference in New Issue