long entryId = ParamUtil.getLong(actionRequest, "entryId");
long userId = themeDisplay.getUserId();
User currentUser = UserLocalServiceUtil.getUser(userId);
Warrant warrant = WarrantLocalServiceUtil.getWarrant(entryId);
boolean isAdmin = false;
List<Role> roles = currentUser.getRoles();
for(Role r : roles){
if(!"WC Admin".equalsIgnoreCase(r.getName())){
isAdmin = true;
}
}
if(warrant.getUserId() != userId){
if(!isAdmin){
System.out.println("This user does not have rights to delete this warrant : "+userId);
return;
}
}
System.out.println("WarrantLocalService, marking Warrant as deleted : "+entryId);
warrant.setStatus(WarrantStateType.DELETED.name());
WarrantLocalServiceUtil.updateWarrant(warrant);
// WarrantLocalServiceUtil.deleteWarrant(entryId);
}