if (em.isCollectionMember(groupRef, Schema.COLLECTION_USERS, userRef)) { try { organizations.put(entity.getUuid(), path);
@Override public void addAdminUserToOrganization( UserInfo user, OrganizationInfo organization, boolean email ) throws Exception { if ( ( user == null ) || ( organization == null ) ) { return; } EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); EntityRef orgRef = new SimpleEntityRef( Group.ENTITY_TYPE, organization.getUuid() ); EntityRef userRef = new SimpleEntityRef( User.ENTITY_TYPE, user.getUuid() ); if(em.isCollectionMember(orgRef, Schema.COLLECTION_USERS, userRef)) { if(logger.isDebugEnabled()) { logger.debug( "addAdminUserToOrganization - Found value: {} already in collection", user.getName() ); } return; } em.addToCollection(orgRef, Schema.COLLECTION_USERS, userRef); invalidateManagementAppAuthCache(); if ( email ) { sendAdminUserInvitedEmail(user, organization); } }
if ( !em.isCollectionMember( context.getOwner(), context.getCollectionName(), entity ) ) { if ( !em.isCollectionMember( context.getOwner(), context.getCollectionName(), entity ) ) { logger.error( "Edge read repair failed for entity id {} with owner {} in collection {}", id, context.getOwner(), context.getCollectionName());
assertTrue( em.isCollectionMember( createdUser, "devices", createdDevice ) ); assertFalse( em.isCollectionMember( createdUser2, "devices", createdDevice ) );
@Test public void testGetByIdAndNameEdgeReadRepair() throws Exception { EntityManager em = setup.getEmf().getEntityManager( app.getId() ); Entity contributor = app.doCreate( "contributor", "Malaka" ); EntityRef appRef = new SimpleEntityRef("application", app.getId()); em.removeItemFromCollection(appRef, InflectionUtils.pluralize(contributor.getType()), contributor); assertFalse("Entity should not have an edge from app to entity", em.isCollectionMember(appRef, InflectionUtils.pluralize(contributor.getType()), contributor)); app.testRequest( ServiceAction.GET, 1, "contributor", contributor.getName()); assertTrue("Entity should now be member of the collection", em.isCollectionMember(appRef, InflectionUtils.pluralize(contributor.getType()), contributor)); } }