use of org.geosdi.geoplatform.gui.model.message.IGPClientMessage in project geo-platform by geosdi.
the class DTOSecurityConverter method convertAccountToDTO.
public IGPAccountDetail convertAccountToDTO(GPAccount account, GPAccountProject accountProject, GPViewport viewport, List<GPMessage> messages) {
GPLoginUserDetail accountDetail = new GPLoginUserDetail();
UserTreeOptions usertreeOptions = new UserTreeOptions();
accountDetail.setId(account.getId());
// Forced representation
accountDetail.setUsername(account.getNaturalID());
accountDetail.setOrganization(account.getOrganization().getName());
usertreeOptions.setLoadExpandedFolders(account.isLoadExpandedFolders());
accountDetail.setTreeOptions(usertreeOptions);
if (account instanceof GPUser) {
GPUser user = (GPUser) account;
accountDetail.setName(user.getName());
accountDetail.setEmail(user.getEmailAddress());
this.extractGPAuthoritiesInToUser(accountDetail, account.getGPAuthorities());
}
if (account.getGsAccount() != null) {
accountDetail.setAuthkey(account.getGsAccount().getAuthkey());
}
accountDetail.setHostXmppServer(hostXmppServer);
if (accountProject != null) {
accountDetail.setBaseLayer(accountProject.getBaseLayer());
}
if (viewport != null) {
GPBBox serverBBOX = viewport.getBbox();
BBoxClientInfo clientBBOX = new BBoxClientInfo(serverBBOX.getMinX(), serverBBOX.getMinY(), serverBBOX.getMaxX(), serverBBOX.getMaxY());
GPClientViewport clientViewport = new GPClientViewport(viewport.getName(), viewport.getDescription(), clientBBOX, viewport.getZoomLevel(), viewport.isIsDefault());
accountDetail.setViewport(clientViewport);
}
if (messages != null) {
List<IGPClientMessage> unreadMessages = Lists.newArrayListWithCapacity(messages.size());
for (GPMessage message : messages) {
GPClientMessage clientMessage = this.convertMessage(message);
unreadMessages.add(clientMessage);
logger.debug("\n*** {}", clientMessage);
}
Collections.sort(unreadMessages);
accountDetail.setUnreadMessages(unreadMessages);
}
return (IGPAccountDetail) accountDetail;
}
use of org.geosdi.geoplatform.gui.model.message.IGPClientMessage in project geo-platform by geosdi.
the class NotificationCenterAction method componentSelected.
@Override
public void componentSelected(ButtonEvent e) {
// RootLayoutPanel.get().add(new BinderDeckLayout());
// this.binderDeckLayout.setVisible(Boolean.TRUE);
// notificationPopupPanel.setStyleName(style.notifypopup());
notificationPopupPanel.setPopupPosition(e.getTarget().getAbsoluteLeft() - (170), e.getTarget().getAbsoluteTop() + (20));
notificationPopupPanel.show();
IGPAccountDetail accountDetail = Registry.get(UserSessionEnum.ACCOUNT_DETAIL_IN_SESSION.name());
List<IGPClientMessage> messageList = accountDetail.getUnreadMessages();
if (messageList != null && !messageList.isEmpty()) {
xsrf.getNewXsrfToken(new AsyncCallback<XsrfToken>() {
@Override
public void onFailure(Throwable caught) {
try {
throw caught;
} catch (RpcTokenException e) {
// Can be thrown for several reasons:
// - duplicate session cookie, which may be a sign of a cookie
// overwrite attack
// - XSRF token cannot be generated because session cookie isn't
// present
} catch (Throwable e) {
// unexpected
}
}
@Override
public void onSuccess(XsrfToken token) {
((HasRpcToken) notificationRemote).setRpcToken(token);
notificationRemote.markMessagesAsRead(new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
if (caught.getCause() instanceof GPSessionTimeout) {
GPHandlerManager.fireEvent(new GPLoginEvent(null));
} else {
GeoPlatformMessage.errorMessage(NotificationModuleConstants.INSTANCE.NotificationCenterAction_errorSavingReadMessagesText(), WindowsConstants.INSTANCE.errorMakingConnectionBodyText());
LayoutManager.getInstance().getStatusMap().setStatus(NotificationModuleConstants.INSTANCE.NotificationCenterAction_errorSavingReadMessagesText(), SearchStatus.EnumSearchStatus.STATUS_NO_SEARCH.toString());
System.out.println("Error Saving the read messages: " + caught.toString() + " data: " + caught.getMessage());
}
}
@Override
public void onSuccess(Boolean result) {
}
});
}
});
}
}
use of org.geosdi.geoplatform.gui.model.message.IGPClientMessage in project geo-platform by geosdi.
the class NotificationCenter method initComponent.
private void initComponent() {
IGPAccountDetail accountDetail = Registry.get(UserSessionEnum.ACCOUNT_DETAIL_IN_SESSION.name());
List<IGPClientMessage> messageList = accountDetail.getUnreadMessages();
if (messageList != null && !messageList.isEmpty()) {
for (IGPClientMessage message : messageList) {
SingleNotify component = new SingleNotify(message);
listComponent.add(component);
}
} else {
// TODO: Inserire un messaggio per avvertire che non ci sono messaggi
// non letti
System.out.println(" Non ci sono messaggi non letti ");
}
}
Aggregations