mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
[CST-12108] improve code
This commit is contained in:
@@ -14,10 +14,8 @@ import java.util.Date;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.QAEvent;
|
import org.dspace.content.QAEvent;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.qaevent.service.QAEventService;
|
import org.dspace.qaevent.service.QAEventService;
|
||||||
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
@@ -39,14 +37,14 @@ public class ReinstateCorrectionType implements CorrectionType, InitializingBean
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private QAEventService qaEventService;
|
private QAEventService qaEventService;
|
||||||
@Autowired
|
|
||||||
private AuthorizeService authorizeService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Context context, Item targetItem) throws SQLException, AuthorizeException {
|
public boolean isAllowed(Context context, Item targetItem) throws SQLException {
|
||||||
authorizeService.authorizeAction(context, targetItem, Constants.READ);
|
if (!targetItem.isWithdrawn()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
long tot = qaEventService.countSourcesByTarget(context, targetItem.getID());
|
long tot = qaEventService.countSourcesByTarget(context, targetItem.getID());
|
||||||
return tot == 0 && targetItem.isWithdrawn();
|
return tot == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -43,10 +43,17 @@ public class WithdrawnCorrectionType implements CorrectionType, InitializingBean
|
|||||||
private AuthorizeService authorizeService;
|
private AuthorizeService authorizeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Context context, Item targetItem) throws AuthorizeException, SQLException {
|
public boolean isAllowed(Context context, Item targetItem) throws SQLException {
|
||||||
|
if (targetItem.isWithdrawn() || !targetItem.isArchived()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
authorizeService.authorizeAction(context, targetItem, READ);
|
authorizeService.authorizeAction(context, targetItem, READ);
|
||||||
|
} catch (AuthorizeException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
long tot = qaEventService.countSourcesByTarget(context, targetItem.getID());
|
long tot = qaEventService.countSourcesByTarget(context, targetItem.getID());
|
||||||
return tot == 0 && targetItem.isArchived() && !targetItem.isWithdrawn();
|
return tot == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user