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();
|
CMItemStatus cmItemStatus = getRequestedCMItemStatus();
|
||||||
|
|
||||||
|
this.apiKey = CKANUtility.getSysAdminAPI();
|
||||||
|
|
||||||
if(!ckanUser.isCatalogueModerator()) {
|
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()) {
|
switch (ckanUser.getRole()) {
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
case MANAGER:
|
case MANAGER:
|
||||||
break;
|
|
||||||
|
|
||||||
case EDITOR:
|
case EDITOR:
|
||||||
q = String.format("%s AND %s:%s", q, AUTHOR_EMAIL_KEY, ckanUser.getEMail());
|
|
||||||
parameters.put(GCatConstants.Q_KEY, q);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMBER:
|
case MEMBER:
|
||||||
if(cmItemStatus!=null && cmItemStatus!=CMItemStatus.APPROVED) {
|
if(cmItemStatus!=null && cmItemStatus!=CMItemStatus.APPROVED) {
|
||||||
throw new ForbiddenException("You are only authorized to list " + CMItemStatus.APPROVED.getValue() + " items");
|
throw new ForbiddenException("You are only authorized to list " + CMItemStatus.APPROVED.getValue() + " items");
|
||||||
}
|
}
|
||||||
cmItemStatus = CMItemStatus.APPROVED;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmItemStatus!=null) {
|
if(cmItemStatus==null) {
|
||||||
stringBuffer.append(cmItemStatus.getValue());
|
cmItemStatus = CMItemStatus.APPROVED;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
parameters.put(INCLUDE_PRIVATE_KEY, String.valueOf(true));
|
||||||
}else{
|
}else{
|
||||||
if(ckanUser.getRole().ordinal()>=Role.ADMIN.ordinal()) {
|
if(ckanUser.getRole().ordinal()>=Role.ADMIN.ordinal()) {
|
||||||
|
|
Loading…
Reference in New Issue