public String send() throws Exception { List<?> list = userLogic.findAll(); if (0 != list.size()) { Long userId[] = new Long[list.size()]; int count = 0; for (Iterator<?> it = list.iterator(); it.hasNext(); ) { User user = (User) it.next(); userId[count] = user.getId(); count++; } if (null != inbox) { if (null != inbox.getSend() && null != inbox.getContent() && null != inbox.getTitle()) { inbox.setDate(new Date()); inbox.setSymbol(ALL); Outbox outbox = getOutbox(); if (0 != count) { if (null != inboxLogic.send(inbox) && null != outboxLogic.send(outbox, userId)) { return SUCCESS; } else { addActionError(getText("error.inbox.fail")); } } else { addActionError(getText("error.inbox.user.isNull")); } } } } return INPUT; }
public void prepare() throws Exception { String userName = (String) ActionContext.getContext().getSession().get("currentUser"); if (null != userName) { User user = userLogic.getUserByUserName(userName); if (null != inbox) { inbox.setSend(user.getName()); } else { inbox = new Inbox(); inbox.setSend(user.getName()); } } }