Does not try to modify metacontact list storage when adding contact to a non persistent group.

fix-message-formatting
Damian Minkov 11 years ago
parent 56882c66bd
commit a56bc6cac6

@ -1265,6 +1265,11 @@ private Element createMetaContactGroupNode(MetaContactGroup metaGroup)
*/
public void metaContactAdded(MetaContactEvent evt)
{
// if the parent group is not persistent, do not do anything
// cause its missing in xml
if(!evt.getParentGroup().isPersistent())
return;
Element parentGroupNode =
findMetaContactGroupNode(evt.getParentGroup().getMetaUID());

@ -294,4 +294,9 @@ public Collection<ContactResource> getResources()
{
return null;
}
public void setPersistent(boolean isPersistent)
{
this.isPersistent = isPersistent;
}
}

@ -495,5 +495,9 @@ public boolean equals(Object obj)
return true;
}
public void setPersistent(boolean isPersistent)
{
this.isPersistent = isPersistent;
}
}

@ -529,4 +529,72 @@ public ContactGroup createUnresolvedContactGroup(String groupUID,
return newGroup;
}
/**
* Creates a non persistent contact for the specified id. This would
* also create (if necessary) a group for volatile contacts.
* @param id the address of the contact to create.
* @return the newly created volatile <tt>MockContact</tt>
*/
public MockContact createVolatileContact(
String id)
{
MockContact newVolatileContact
= new MockContact(id, parentProvider);
newVolatileContact.setResolved(false);
newVolatileContact.setPersistent(false);
//Check whether a volatile group already exists and if not create
//one
MockContactGroup theVolatileGroup = getNonPersistentGroup();
//if the parent group is null then add necessary create the group
if (theVolatileGroup == null)
{
theVolatileGroup = new MockContactGroup(
"Not-In-Contactlist",
parentProvider);
theVolatileGroup.setResolved(false);
theVolatileGroup.setPersistent(false);
theVolatileGroup.addContact(newVolatileContact);
this.contactListRoot.addSubgroup(theVolatileGroup);
fireServerStoredGroupEvent(theVolatileGroup
, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
}
else
{
theVolatileGroup.addContact(newVolatileContact);
fireSubscriptionEvent(
newVolatileContact,
theVolatileGroup,
SubscriptionEvent.SUBSCRIPTION_CREATED);
}
return newVolatileContact;
}
/**
* Returns the volatile group that we use when creating volatile contacts.
*
* @return MockContactGroup
*/
public MockContactGroup getNonPersistentGroup()
{
String groupName = "Not-In-Contactlist";
for (int i = 0; i < contactListRoot.countSubgroups(); i++)
{
MockContactGroup gr =
(MockContactGroup)contactListRoot.getGroup(i);
if(!gr.isPersistent() && gr.getGroupName().equals(groupName))
return gr;
}
return null;
}
}

@ -476,6 +476,13 @@ public void testSubscriptionHandling() throws Exception
assertEquals("Source meta contact."
, newMetaContact, evt.getSourceMetaContact());
MclSlickFixture.mockPresOpSet.createVolatileContact(
newSubscriptionName + "1");
MclSlickFixture.mockPresOpSet.createVolatileContact(
newSubscriptionName + "2");
// and now clear volatile
MclSlickFixture.mockPresOpSet.removeServerStoredContactGroup(
MclSlickFixture.mockPresOpSet.getNonPersistentGroup());
}

Loading…
Cancel
Save