Commit e5e5b82c by Tuomas Riihimäki

logging fixes after merge

1 parent 45d28884
......@@ -37,6 +37,7 @@ import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/**
* Session Bean implementation class ProductPBean
......@@ -60,8 +61,7 @@ public class ProductPBean {
private ProductFacade productFacade;
@EJB
private LoggingBean lbean;
private LoggingBeanLocal lbean;
private static final Logger logger = LoggerFactory
.getLogger(ProductPBean.class);
......@@ -104,16 +104,15 @@ public class ProductPBean {
throw new EJBException("Trying to create accountevent for different event in user and product");
}
BigDecimal unitPrice = product.getPrice().negate();
List<Discount> discounts = new ArrayList<>();
if(overriddenUnitPrice != null && BigDecimal.ZERO.compareTo(overriddenUnitPrice) < 0) {
if (overriddenUnitPrice != null && BigDecimal.ZERO.compareTo(overriddenUnitPrice) < 0) {
unitPrice = overriddenUnitPrice;
lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User creating accountevent with discount");
lbean.sendMessage(MoyaEventType.ACCOUNTEVENT_INFO, permbean.getCurrentUser(), "User creating accountevent with discount");
// lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User creating accountevent with discount");
} else {
// no discounts if custom price
......@@ -159,7 +158,7 @@ public class ProductPBean {
// flush changes to db.
// userFacade.flush();
lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User created accountevent: ", ret.getId());
lbean.sendMessage(MoyaEventType.ACCOUNTEVENT_INFO, permbean.getCurrentUser(), "User created accountevent: ", ret.getId());
return ret;
}
}
......@@ -406,7 +406,7 @@ public class UserBean implements UserBeanLocal {
} else {
ret = userimagefacade.find(id);
if (ret != null && !permbean.isCurrentUser(ret.getUser()) && permbean.hasPermission(UserPermission.MODIFY)) {
loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enough rights to access image id: " + id + " for user " + ret.getUser());
loggerbean.sendMessage(MoyaEventType.USER_INSUFFICIENT_PERMISSIONS, permbean.getCurrentUser(), "Not enough rights to access image id: ", id, " for user ", ret.getUser());
throw new EJBAccessException("Not enough permissions to fetch image");
}
......@@ -698,7 +698,7 @@ public class UserBean implements UserBeanLocal {
// At the very least it safeguards the situation if user gets another
// users gameid in somehow..
if (!permbean.isCurrentUser(gi.getEventUser())) {
loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "User tried to remove GameID from another user: " + gi.getEventUser());
loggerbean.sendMessage(MoyaEventType.USER_INSUFFICIENT_PERMISSIONS, permbean.getCurrentUser(), "User tried to remove GameID from another user: ", gi.getEventUser());
throw new EJBAccessException("Not enough rights to remove another users' GameIDs");
}
......@@ -727,7 +727,7 @@ public class UserBean implements UserBeanLocal {
@RolesAllowed(SpecialPermission.S_USER)
public EventUser mergeEventUserChanges(EventUser user) {
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(UserPermission.MODIFY)) {
loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "User tried to save another user: " + user);
loggerbean.sendMessage(MoyaEventType.USER_INSUFFICIENT_PERMISSIONS, permbean.getCurrentUser(), "User tried to save another user: ", user);
throw new EJBAccessException("Not enough rights to save user");
}
......
......@@ -71,4 +71,14 @@ public class MoyaEventSender implements LoggingBeanLocal {
sendMessage(msg);
}
@Override
public void sendMessage(MoyaEventType type, EventUser user, Object... message) {
StringBuilder sb = new StringBuilder();
for (Object m : message) {
sb.append(m);
}
sendMessage(type, user, sb.toString());
}
}
......@@ -54,6 +54,7 @@ import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/**
*
......@@ -145,7 +146,7 @@ public class PlaceMapServlet extends HttpServlet {
if (!permbean.hasPermission(MapPermission.VIEW))
{
loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(),
loggerbean.sendMessage(MoyaEventType.USER_INSUFFICIENT_PERMISSIONS, permbean.getCurrentUser(),
"User tried to print the placemap to stream without sufficient permissions");
throw new EJBAccessException("Not enough permissions to print placemap");
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!