public void execute(Event<UIMembersPortlet> event) throws Exception { UIMembersPortlet uiAllPeople = event.getSource(); String userId = event.getRequestContext().getRequestParameter(OBJECTID); Identity inviIdentityIdentity = Utils.getIdentityManager().getIdentity(userId, true); Identity invitingIdentity = Utils.getViewerIdentity(); Relationship relationship = Utils.getRelationshipManager().get(invitingIdentity, inviIdentityIdentity); uiAllPeople.setLoadAtEnd(false); if (relationship != null && relationship.getStatus() == Relationship.Type.CONFIRMED) { Utils.getRelationshipManager().delete(relationship); return; } if (relationship == null) { UIApplication uiApplication = event.getRequestContext().getUIApplication(); uiApplication.addMessage( new ApplicationMessage(INVITATION_REVOKED_INFO, null, ApplicationMessage.INFO)); return; } Utils.clearCacheOnUserPopup(); Utils.getRelationshipManager().deny(inviIdentityIdentity, invitingIdentity); }
public void testToString() { // invitor Identity sender = new Identity("organization", "root"); // invitee Identity receiver = new Identity("organization", "john"); // create relationship Relationship relationship = new Relationship(sender, receiver, Type.PENDING); assertEquals("organization:root--[PENDING]--organization:john", relationship.toString()); }
@Override public void execute(Event<UIInvitations> event) throws Exception { UIInvitations uiInvitations = event.getSource(); String identityId = event.getRequestContext().getRequestParameter(OBJECTID); Identity invitedIdentity = Utils.getIdentityManager().getIdentity(identityId, true); Identity invitingIdentity = Utils.getViewerIdentity(); Relationship relationship = Utils.getRelationshipManager().get(invitingIdentity, invitedIdentity); uiInvitations.setLoadAtEnd(false); if (relationship == null || relationship.getStatus() != Relationship.Type.PENDING) { UIApplication uiApplication = event.getRequestContext().getUIApplication(); uiApplication.addMessage( new ApplicationMessage(INVITATION_REVOKED_INFO, null, ApplicationMessage.INFO)); return; } Utils.getRelationshipManager().deny(invitedIdentity, invitingIdentity); Utils.clearCacheOnUserPopup(); event.getRequestContext().addUIComponentToUpdateByAjax(uiInvitations); }