r7298 - in dumbhippo/trunk/server: src/com/dumbhippo/server src/com/dumbhippo/server/impl src/com/dumbhippo/web/pages web/tags/3
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7298 - in dumbhippo/trunk/server: src/com/dumbhippo/server src/com/dumbhippo/server/impl src/com/dumbhippo/web/pages web/tags/3
- Date: Thu, 7 Feb 2008 17:45:05 -0600 (CST)
Author: marinaz
Date: 2008-02-07 17:45:05 -0600 (Thu, 07 Feb 2008)
New Revision: 7298
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/PersonViewer.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AbstractPersonPage.java
dumbhippo/trunk/server/web/tags/3/requirePersonBean.tag
Log:
Don't try to include invitations for resources who already have accounts claiming them
in the list of invitations created by the inviter (this used to cause an exception).
Such accounts are already included in the Network of the inviter.
Don't display contacts whose accounts are not public in the Network of the inviter.
Instead, display them in the "People I've Invited to Join Mugshot" section if their
is an explicit contact claim between the inviter and the contact's e-mail address.
Most likely the person has invited them at some point if there is such a contact claim.
Omit users with disabled accounts if such contact claim does not exist.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/PersonViewer.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/PersonViewer.java 2008-02-07 20:47:16 UTC (rev 7297)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/PersonViewer.java 2008-02-07 23:45:05 UTC (rev 7298)
@@ -68,6 +68,8 @@
public void pageUserContactsAlphaSorted(Viewpoint viewpoint, User user, Pageable<PersonView> pageable);
+ public List<PersonView> getUserContactsWithDisabledAccounts(Viewpoint viewpoint, User user);
+
/**
* Get the contacts of the user who do not have accounts associated with them,
* and have not received invitations to the system from the user.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java 2008-02-07 20:47:16 UTC (rev 7297)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java 2008-02-07 23:45:05 UTC (rev 7298)
@@ -246,16 +246,25 @@
// get only the InvitationTokens for which ResultingPerson is null,
// sorted by date in descending order, filter out older invitations
// to the same recipient
+ // Sometimes we have invitations that do not have a resulting person
+ // set, even though there is a user who is claiming the invitee resource
+ // in the system. We only set resulting person when a particular invitation
+ // token is viewed (getResultingPerson on InvitationToken is OneToOne).
+ // So there might be other (expired) invitations that still have resultingPerson
+ // set to null. A user might also bypass viewing an invitation if they already
+ // have an account and add the e-mail address an invitation was sent to to
+ // that account.
Query q = em.createQuery(
"SELECT ivd.invitation FROM InviterData ivd " +
" WHERE ivd.inviter = :inviter AND " +
" ivd.deleted = FALSE AND " +
- " ivd.invitation.resultingPerson = NULL AND " +
+ " ivd.invitation.resultingPerson IS NULL AND " +
" NOT EXISTS (SELECT it.id FROM InvitationToken it, InviterData ivd2 " +
" WHERE it.invitee = ivd.invitation.invitee AND" +
" ivd2.inviter = :inviter AND" +
" it.creationDate > ivd.invitation.creationDate AND" +
- " ivd2.invitation = it)" +
+ " ivd2.invitation = it) AND " +
+ " NOT EXISTS (SELECT ac.id from AccountClaim ac where ac.resource = ivd.invitation.invitee)" +
" ORDER BY ivd.invitation.creationDate DESC");
q.setParameter("inviter", inviter);
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java 2008-02-07 20:47:16 UTC (rev 7297)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java 2008-02-07 23:45:05 UTC (rev 7298)
@@ -9,6 +9,7 @@
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -445,15 +446,33 @@
"SELECT "
+ (forCount ? "COUNT(DISTINCT owner.id)"
: "DISTINCT owner")
- + " FROM Contact c, ContactClaim cc, AccountClaim acctClaim, User owner WHERE "
+ + " FROM Contact c, ContactClaim cc, AccountClaim acctClaim, User owner, Account a WHERE "
+ " c.account = :startAccount AND cc.contact = c AND cc.resource = acctClaim.resource "
- + " AND acctClaim.owner = owner AND acctClaim.owner != :startOwner"
+ + " AND acctClaim.owner = owner AND acctClaim.owner != :startOwner AND a.owner = owner"
+ + " AND a.disabled = 0 AND a.adminDisabled = 0 AND a.hasAcceptedTerms = 1 AND a.publicPage = 1"
+ (forCount ? ""
: " ORDER BY upper(owner.nickname) ASC"))
.setParameter("startOwner", user).setParameter("startAccount",
user.getAccount());
}
+
+ private Query getUserContactsWithDisabledAccountsQuery(User user, boolean forCount) {
+ return em
+ .createQuery(
+ "SELECT "
+ + (forCount ? "COUNT(DISTINCT owner.id)"
+ : "DISTINCT owner")
+ + " FROM Contact c, ContactClaim cc, AccountClaim acctClaim, User owner, Account a WHERE "
+ + " c.account = :startAccount AND cc.contact = c AND cc.resource = acctClaim.resource "
+ + " AND acctClaim.owner = owner AND acctClaim.owner != :startOwner AND a.owner = owner"
+ + " AND (a.disabled = 1 OR a.adminDisabled = 1 OR a.hasAcceptedTerms = 0 OR a.publicPage = 0)"
+ + (forCount ? ""
+ : " ORDER BY upper(owner.nickname) ASC"))
+ .setParameter("startOwner", user).setParameter("startAccount",
+ user.getAccount());
+ }
+
private Query getContactsWithoutInvitesQuery(User user) {
return em.createQuery(
"SELECT DISTINCT cc.resource "
@@ -580,6 +599,45 @@
pageable.setTotalCount(getUserContactCount(viewpoint, user));
}
+ private Contact getEmailContactForUser(User contacter, User user) {
+ Query q = em.createQuery("SELECT cc.contact " +
+ " FROM ContactClaim cc, AccountClaim ac " +
+ " WHERE cc.account = :contacterAccount" +
+ " AND cc.resource = ac.resource "+
+ " AND ac.owner = :user " +
+ " AND EXISTS (SELECT id FROM EmailResource er WHERE er = cc.resource)");
+ q.setParameter("contacterAccount", contacter.getAccount());
+ q.setParameter("user", user);
+ q.setMaxResults(1);
+
+ try {
+ return (Contact)q.getSingleResult();
+ } catch (NoResultException e) {
+ return null;
+ }
+ }
+
+ public List<PersonView> getUserContactsWithDisabledAccounts(Viewpoint viewpoint, User user) {
+
+ if (!(viewpoint instanceof SystemViewpoint) && !viewpoint.isOfUser(user))
+ return Collections.emptyList();
+
+ Query q = getUserContactsWithDisabledAccountsQuery(user, false);
+ List<PersonView> viewedContacts = new ArrayList<PersonView>();
+ for (User result : TypeUtils.castList(User.class, q.getResultList())) {
+ Contact contact = getEmailContactForUser(user, result);
+ // We are just going to omit the contact if the person never claimed to know their e-mail
+ // address.
+ if (contact != null) {
+ PersonView pv = constructPersonView(viewpoint, contact, null, PersonView.class);
+ addPersonViewExtras(viewpoint, pv, null);
+ viewedContacts.add(pv);
+ }
+ }
+
+ return viewedContacts;
+ }
+
public List<PersonView> getContactsWithoutInvites(Viewpoint viewpoint, User user) {
if (!viewpoint.isOfUser(user))
return Collections.emptyList();
Modified: dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AbstractPersonPage.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AbstractPersonPage.java 2008-02-07 20:47:16 UTC (rev 7297)
+++ dumbhippo/trunk/server/src/com/dumbhippo/web/pages/AbstractPersonPage.java 2008-02-07 23:45:05 UTC (rev 7298)
@@ -386,22 +386,23 @@
return pageableFollowers;
}
- private ListBean<PersonView> convertToPersonViews(List<InvitationView> invitationViews) {
+ private List<PersonView> convertToPersonViews(List<InvitationView> invitationViews) {
List<PersonView> personViewsList = new ArrayList<PersonView>();
for (InvitationView invitation : invitationViews) {
PersonView personView =
personViewer.getPersonView(getUserSignin().getViewpoint(), invitation.getInvite().getInvitee());
+ logger.debug("invitee: {} personView: {}", invitation.getInvite().getInvitee(), personView);
personView.setInvitationView(invitation);
personViewsList.add(personView);
}
- return new ListBean<PersonView>(personViewsList);
+ return personViewsList;
}
public ListBean<PersonView> getOutstandingInvitations() {
if (outstandingInvitations == null) {
outstandingInvitations =
- convertToPersonViews(invitationSystem.findInvitations(getUserSignin().getViewpoint(),
- 0, -1, false));
+ new ListBean<PersonView>(convertToPersonViews(invitationSystem.findInvitations(getUserSignin().getViewpoint(),
+ 0, -1, false)));
}
return outstandingInvitations;
}
@@ -418,10 +419,13 @@
public ListBean<PersonView> getInvitedContacts() {
- if (invitedContacts == null) {
- invitedContacts =
+ if (invitedContacts == null) {
+ List<PersonView> invitedContactsList =
convertToPersonViews(invitationSystem.findInvitations(getUserSignin().getViewpoint(),
0, -1, true));
+ invitedContactsList.addAll(personViewer.getUserContactsWithDisabledAccounts(getUserSignin().getViewpoint(),
+ getViewedUser()));
+ invitedContacts = new ListBean<PersonView>(invitedContactsList);
}
return invitedContacts;
}
Modified: dumbhippo/trunk/server/web/tags/3/requirePersonBean.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/requirePersonBean.tag 2008-02-07 20:47:16 UTC (rev 7297)
+++ dumbhippo/trunk/server/web/tags/3/requirePersonBean.tag 2008-02-07 23:45:05 UTC (rev 7298)
@@ -31,7 +31,7 @@
</c:choose>
<c:if test="${!person.valid}">
- <dht:errorPage>Person not found (log in?)</dht:errorPage>
+ <dht:errorPage>Person not found. Possibly their account was disabled.</dht:errorPage>
</c:if>
</c:when>
<c:when test="${!dh:myInstanceOf(person, beanClass)}">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]