fixed delete message in sent messages
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/message-conversations@154403 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5e8d256a79
commit
b8642ea79d
|
@ -21,5 +21,5 @@ public interface MessageService extends RemoteService {
|
||||||
boolean deleteMessageById(String messageId, boolean sent);
|
boolean deleteMessageById(String messageId, boolean sent);
|
||||||
String getAttachmentDownloadURL(String itemId);
|
String getAttachmentDownloadURL(String itemId);
|
||||||
boolean saveAttachmentToWorkspaceFolder(String itemId, String destinationFolderId);
|
boolean saveAttachmentToWorkspaceFolder(String itemId, String destinationFolderId);
|
||||||
boolean markMessageUnread(String messageId);
|
boolean markMessageUnread(String messageId, boolean sent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package org.gcube.portets.user.message_conversations.client.event;
|
|
||||||
|
|
||||||
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class DeleteMessageEvent extends GwtEvent<DeleteMessageEventHandler> {
|
|
||||||
public static Type<DeleteMessageEventHandler> TYPE = new Type<DeleteMessageEventHandler>();
|
|
||||||
|
|
||||||
private ConvMessage m;
|
|
||||||
private boolean sent;
|
|
||||||
public DeleteMessageEvent(ConvMessage m, boolean sent) {
|
|
||||||
this.m = m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConvMessage getMessage() {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSent() {
|
|
||||||
return sent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<DeleteMessageEventHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(DeleteMessageEventHandler handler) {
|
|
||||||
handler.onDeleteMessage(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.portets.user.message_conversations.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface DeleteMessageEventHandler extends EventHandler {
|
|
||||||
void onDeleteMessage(DeleteMessageEvent event);
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package org.gcube.portets.user.message_conversations.client.event;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class NewMessageEvent extends GwtEvent<NewMessageEventHandler> {
|
|
||||||
public static Type<NewMessageEventHandler> TYPE = new Type<NewMessageEventHandler>();
|
|
||||||
|
|
||||||
|
|
||||||
private String text;
|
|
||||||
private HashSet<String> mentionedUsers;
|
|
||||||
|
|
||||||
public NewMessageEvent() {
|
|
||||||
|
|
||||||
this.text = text;
|
|
||||||
this.mentionedUsers = mentionedUsers;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<String> getMentionedUsers() {
|
|
||||||
return mentionedUsers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<NewMessageEventHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(NewMessageEventHandler handler) {
|
|
||||||
handler.onNewMessage(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.portets.user.message_conversations.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface NewMessageEventHandler extends EventHandler {
|
|
||||||
void onNewMessage(NewMessageEvent event);
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||||
import org.gcube.portets.user.message_conversations.client.MessageService;
|
import org.gcube.portets.user.message_conversations.client.MessageService;
|
||||||
import org.gcube.portets.user.message_conversations.client.MessageServiceAsync;
|
import org.gcube.portets.user.message_conversations.client.MessageServiceAsync;
|
||||||
import org.gcube.portets.user.message_conversations.client.Utils;
|
import org.gcube.portets.user.message_conversations.client.Utils;
|
||||||
import org.gcube.portets.user.message_conversations.client.event.DeleteMessageEvent;
|
|
||||||
import org.gcube.portets.user.message_conversations.client.ui.resources.MessagesResources;
|
import org.gcube.portets.user.message_conversations.client.ui.resources.MessagesResources;
|
||||||
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
||||||
import org.gcube.portets.user.message_conversations.shared.MessageUserModel;
|
import org.gcube.portets.user.message_conversations.shared.MessageUserModel;
|
||||||
|
@ -174,11 +173,10 @@ public class ApplicationView extends Composite {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
* @param sent
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void deleteMessage(final DeleteMessageEvent event) {
|
public void deleteMessage(final ConvMessage toDelete, boolean sent) {
|
||||||
final ConvMessage toDelete = event.getMessage();
|
|
||||||
boolean sent = event.isSent();
|
|
||||||
convService.deleteMessageById(toDelete.getId(), sent, new AsyncCallback<Boolean>() {
|
convService.deleteMessageById(toDelete.getId(), sent, new AsyncCallback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -188,7 +186,7 @@ public class ApplicationView extends Composite {
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
MaterialToast.fireToast("Message Deleted ("+toDelete.getSubject()+")");
|
MaterialToast.fireToast("Message Deleted ("+toDelete.getSubject()+")");
|
||||||
totalMessages = totalMessages - 1;
|
totalMessages = totalMessages - 1;
|
||||||
updateBadge(event.isSent());
|
updateBadge(sent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -197,8 +195,8 @@ public class ApplicationView extends Composite {
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void setMessageUnread(ConvMessage toSet) {
|
public void setMessageUnread(ConvMessage toSet, boolean sent) {
|
||||||
convService.markMessageUnread(toSet.getId(), new AsyncCallback<Boolean>() {
|
convService.markMessageUnread(toSet.getId(), sent, new AsyncCallback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
}
|
}
|
||||||
|
@ -367,7 +365,7 @@ public class ApplicationView extends Composite {
|
||||||
List<MessageUserModel> recipients = Arrays.asList(new MessageUserModel(0, "you", "You", ""));
|
List<MessageUserModel> recipients = Arrays.asList(new MessageUserModel(0, "you", "You", ""));
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
MessageUserModel sender = new MessageUserModel(0, "jarvis", "D4Science Team", images.d4scienceTeam().getURL(), "", "");
|
MessageUserModel sender = new MessageUserModel(0, "jarvis", "D4Science Team", images.d4scienceTeam().getURL(), "", "");
|
||||||
ConvMessage welcomeMessage = new ConvMessage("0", "Welcome to your Messages", sender, recipients , new Date(), MessagesResources.WELCOME_MESSAGE, true);
|
ConvMessage welcomeMessage = new ConvMessage("0", "Welcome to your Messages", sender, recipients , new Date(), MessagesResources.WELCOME_MESSAGE, true, false);
|
||||||
FAB.setVisible(false);
|
FAB.setVisible(false);
|
||||||
displayMessage.showMessage(welcomeMessage);
|
displayMessage.showMessage(welcomeMessage);
|
||||||
welcomeMessage.setContent(MessagesResources.WELCOME_MESSAGE.substring(0, 102)+ " ...");
|
welcomeMessage.setContent(MessagesResources.WELCOME_MESSAGE.substring(0, 102)+ " ...");
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.gcube.portets.user.message_conversations.client.ui;
|
package org.gcube.portets.user.message_conversations.client.ui;
|
||||||
|
|
||||||
import org.gcube.portets.user.message_conversations.client.Utils;
|
import org.gcube.portets.user.message_conversations.client.Utils;
|
||||||
import org.gcube.portets.user.message_conversations.client.event.DeleteMessageEvent;
|
|
||||||
import org.gcube.portets.user.message_conversations.client.ui.resources.MessagesResources;
|
import org.gcube.portets.user.message_conversations.client.ui.resources.MessagesResources;
|
||||||
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
import org.gcube.portets.user.message_conversations.shared.ConvMessage;
|
||||||
|
|
||||||
|
@ -153,15 +152,14 @@ public class MessageItem extends Composite {
|
||||||
@UiHandler("setUnreadButton")
|
@UiHandler("setUnreadButton")
|
||||||
void onSetUnread(ClickEvent e) {
|
void onSetUnread(ClickEvent e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
ap.setMessageUnread(myMessage);
|
ap.setMessageUnread(myMessage, this.sent);
|
||||||
myMessage.setRead(false);
|
myMessage.setRead(false);
|
||||||
item.addStyleName("unread-message");
|
item.addStyleName("unread-message");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doDelete(String subject) {
|
private void doDelete(String subject) {
|
||||||
if (deleteClicked) {
|
if (deleteClicked) {
|
||||||
GWT.log("is sent?"+ this.sent);
|
ap.deleteMessage(myMessage, this.sent);
|
||||||
ap.deleteMessage(new DeleteMessageEvent(myMessage, this.sent));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deleteClicked = true;
|
deleteClicked = true;
|
||||||
|
|
|
@ -159,8 +159,9 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
|
||||||
mu = new MessageUserModel(m.getAddresses().get(0));
|
mu = new MessageUserModel(m.getAddresses().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sent) { //received messages
|
|
||||||
boolean hasAttachments = !m.getAttachmentsIds().isEmpty();
|
boolean hasAttachments = !m.getAttachmentsIds().isEmpty();
|
||||||
|
if (!sent) { //received messages
|
||||||
|
|
||||||
toReturn.add(new ConvMessage(
|
toReturn.add(new ConvMessage(
|
||||||
m.getId(),
|
m.getId(),
|
||||||
m.getSubject(),
|
m.getSubject(),
|
||||||
|
@ -181,7 +182,8 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
|
||||||
recipients,
|
recipients,
|
||||||
new Date(m.getSendTime().getTimeInMillis()),
|
new Date(m.getSendTime().getTimeInMillis()),
|
||||||
previewBody,
|
previewBody,
|
||||||
m.isRead()));
|
m.isRead(),
|
||||||
|
hasAttachments));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -192,7 +194,7 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean markMessageUnread(String messageId) {
|
public boolean markMessageUnread(String messageId, boolean sent) {
|
||||||
GCubeUser user = getCurrentUser(getThreadLocalRequest());
|
GCubeUser user = getCurrentUser(getThreadLocalRequest());
|
||||||
String scope = pContext.getCurrentScope(getThreadLocalRequest());
|
String scope = pContext.getCurrentScope(getThreadLocalRequest());
|
||||||
SecurityTokenProvider.instance.set(pContext.getCurrentUserToken(scope, user.getUserId()));
|
SecurityTokenProvider.instance.set(pContext.getCurrentUserToken(scope, user.getUserId()));
|
||||||
|
@ -200,7 +202,9 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
|
||||||
HomeManagerFactory factory = HomeLibrary.getHomeManagerFactory();
|
HomeManagerFactory factory = HomeLibrary.getHomeManagerFactory();
|
||||||
HomeManager manager = factory.getHomeManager();
|
HomeManager manager = factory.getHomeManager();
|
||||||
Workspace workspace = manager.getHome().getWorkspace();
|
Workspace workspace = manager.getHome().getWorkspace();
|
||||||
workspace.getWorkspaceMessageManager().getReceivedMessage(messageId).setStatus(false);
|
WorkspaceMessage m = (sent) ?
|
||||||
|
workspace.getWorkspaceMessageManager().getSentMessage(messageId): workspace.getWorkspaceMessageManager().getReceivedMessage(messageId);
|
||||||
|
m.setStatus(false);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -55,9 +55,9 @@ public class ConvMessage implements IsSerializable{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//without attchment
|
|
||||||
public ConvMessage(String id, String subject, MessageUserModel owner, List<MessageUserModel> recipients, Date date,
|
public ConvMessage(String id, String subject, MessageUserModel owner, List<MessageUserModel> recipients, Date date,
|
||||||
String content, boolean isRead) {
|
String content, boolean isRead, boolean hasAttachments) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
|
@ -66,6 +66,7 @@ public class ConvMessage implements IsSerializable{
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.isRead = isRead;
|
this.isRead = isRead;
|
||||||
|
this.hasAttachments = hasAttachments;
|
||||||
attachments = new ArrayList<>();
|
attachments = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue