item.addItemField(Params.DISCUSSION_LEVEL.getParamName(), "0");
item.setContentName(Params.DISCUSSION_TEXT.getParamName());
DomainUser writer = DomainUserUtils.getDomainUserByUniqueId(discussion
.getOwnerId(), request.getCurrentDomainUser().getAccount());
item.addItemField(ProfileFields.PROFILE_NICKNAME.getParamName(),
writer.getNickName());
item.addItemField(ProfileFields.PROFILE_TITLE.getParamName(),
writer.getTitle());
if (writer.getPhotoUrl() != null && writer.getPhotoUrl().length() > 0)
item.addItemField(
ProfileFields.PROFILE_THUMBNAILURL.getParamName(),
writer.getPhotoUrl());
item.setGadgetPermissions(discussion.isUserEdit(request),
discussion.isOwnedByMe(request),
discussion.isOwnedByMe(request));
if (replays != null) {
for (Replys replay : replays) {
int level = 0;
item = response.newItem();
item.addItemKeyField(replay.getId());
item.addItemField(Params.DISCUSSION_TEXT.getParamName(),
replay.getReply());
formatedDate = df.format(replay.getCdate());
if (formatedDate != null)
item.addItemField(
Params.DISCUSSION_MSD_DATE.getParamName(),
formatedDate);
else
item.addItemField(
Params.DISCUSSION_MSD_DATE.getParamName(), "");
if (replay.getReplyOrder() != null)
level = replay.getReplyOrder().split("\\*").length - 1;
// this will be used to create UI message indentation
item.addItemField(Params.DISCUSSION_LEVEL.getParamName(),
new Integer(level).toString());
item.setContentName(Params.DICUSSION_REPLY.getParamName());
writer = DomainUserUtils.getDomainUserByUniqueId(replay
.getUserName(), request.getCurrentDomainUser()
.getAccount());
item.addItemField(
ProfileFields.PROFILE_NICKNAME.getParamName(),
writer.getNickName());
item.addItemField(ProfileFields.PROFILE_TITLE.getParamName(),
writer.getTitle());
if (writer.getPhotoUrl() != null
&& writer.getPhotoUrl().length() > 0)
item.addItemField(
ProfileFields.PROFILE_THUMBNAILURL.getParamName(),
writer.getPhotoUrl());
item.setGadgetPermissions(discussion.isUserEdit(request),
false, false);
}