mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +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 org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.QAEvent;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.qaevent.service.QAEventService;
|
||||
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||
@@ -39,14 +37,14 @@ public class ReinstateCorrectionType implements CorrectionType, InitializingBean
|
||||
|
||||
@Autowired
|
||||
private QAEventService qaEventService;
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Override
|
||||
public boolean isAllowed(Context context, Item targetItem) throws SQLException, AuthorizeException {
|
||||
authorizeService.authorizeAction(context, targetItem, Constants.READ);
|
||||
public boolean isAllowed(Context context, Item targetItem) throws SQLException {
|
||||
if (!targetItem.isWithdrawn()) {
|
||||
return false;
|
||||
}
|
||||
long tot = qaEventService.countSourcesByTarget(context, targetItem.getID());
|
||||
return tot == 0 && targetItem.isWithdrawn();
|
||||
return tot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -43,10 +43,17 @@ public class WithdrawnCorrectionType implements CorrectionType, InitializingBean
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Override
|
||||
public boolean isAllowed(Context context, Item targetItem) throws AuthorizeException, SQLException {
|
||||
authorizeService.authorizeAction(context, targetItem, READ);
|
||||
public boolean isAllowed(Context context, Item targetItem) throws SQLException {
|
||||
if (targetItem.isWithdrawn() || !targetItem.isArchived()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
authorizeService.authorizeAction(context, targetItem, READ);
|
||||
} catch (AuthorizeException e) {
|
||||
return false;
|
||||
}
|
||||
long tot = qaEventService.countSourcesByTarget(context, targetItem.getID());
|
||||
return tot == 0 && targetItem.isArchived() && !targetItem.isWithdrawn();
|
||||
return tot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user