@Override public JobStat getStatsForJob( String jobName, UUID jobId ) throws Exception { EntityManager em = emf.getEntityManager( emf.getManagementAppId() ); Query query = Query.fromQL( "select * where " + JOB_NAME + " = '" + jobName + "' AND " + JOB_ID + " = " + jobId ); Results r = em.searchCollection( em.getApplicationRef(), "job_stats", query ); if ( r.size() == 1 ) { return ( JobStat ) r.getEntity(); } return null; }
@Override public boolean newAppUsersNeedAdminApproval( UUID applicationId ) throws Exception { EntityManager em = emf.getEntityManager(applicationId); Boolean registration_requires_admin_approval = ( Boolean ) em .getProperty( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), REGISTRATION_REQUIRES_ADMIN_APPROVAL ); return registration_requires_admin_approval != null && registration_requires_admin_approval; }
@Override public void activateAppUser( UUID applicationId, UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); em.setProperty(new SimpleEntityRef(User.ENTITY_TYPE, userId), "activated", true); }
@Override public Results queryJobData( Query query ) throws Exception { if ( query == null ) { query = new Query(); } String jobDataType = Schema.getDefaultSchema().getEntityType(JobData.class); return getEm().searchCollection( getEm().getApplicationRef(), Schema.defaultCollectionName(jobDataType), query ); }
private Results getResultsFor( EntityRef ref ) { entityRef.setUUID(ref.getUuid()); entityRef.setType(ref.getType()); try { return ( query.getCollection() != null ) ? entityManager.searchCollection( entityRef, query.getCollection(), query ) : entityManager.searchTargetEntities(entityRef, query); } catch ( Exception e ) { throw new RuntimeException( e ); } }
private Set<CredentialsInfo> readUserPasswordHistory( UUID appId, UUID ownerId ) throws Exception { EntityManager em = emf.getEntityManager( appId ); Entity owner = em.get( new SimpleEntityRef("user", ownerId )); @SuppressWarnings("unchecked") Set<CredentialsInfo> credInfo = (Set<CredentialsInfo>)em.getDictionaryElementValue(owner, DICTIONARY_CREDENTIALS, USER_PASSWORD_HISTORY); return credInfo; }
protected Entity getOrganizationEntityForApplication( UUID applicationInfoId ) throws Exception { if ( applicationInfoId == null ) { return null; } final EntityManager em = emf.getEntityManager(smf.getManagementAppId()); Results r = em.getSourceEntities( new SimpleEntityRef(CpNamingUtils.APPLICATION_INFO, applicationInfoId), ORG_APP_RELATIONSHIP, Group.ENTITY_TYPE, Level.ALL_PROPERTIES); return r.getEntity(); }
public void distribute( EntityRef group, Entity activity ) throws Exception { if ( activity == null ) { return; } em.addToCollection( group, "feed", activity ); Results r = em.getCollection( group, "users", null, 10000, Level.REFS, false ); List<EntityRef> refs = r.getRefs(); if ( refs != null ) { em.addToCollections( refs, "feed", activity ); } } }
private CredentialsInfo readCreds( UUID appId, UUID ownerId, String ownerType, String key ) throws Exception { EntityManager em = emf.getEntityManager( appId ); Entity owner = em.get( ownerId ); return ( CredentialsInfo ) em.getDictionaryElementValue( owner, DICTIONARY_CREDENTIALS, key ); }
@Override public User getAppUserByIdentifier( UUID applicationId, Identifier identifier ) throws Exception { EntityManager em = emf.getEntityManager(applicationId); return em.get( em.getUserByIdentifier( identifier ), User.class ); }
@Override public Entity toTypedEntity() { Entity entity = EntityFactory.newEntity( getUuid(), getType() ); entity.setProperties( getProperties() ); return entity; }
public static SimpleRoleRef forRoleEntity( Entity role ) { if ( role == null ) { return null; } UUID groupId = ( UUID ) role.getProperty( "group" ); String name = role.getName(); return new SimpleRoleRef( groupId, name ); }
public Iterator<E> graphIterator( EntityManager em ) { try { if ( uuid != null && type != null ) { return new PagingResultsIterator( getHeadResults( em ), query.getResultsLevel(), null); }else { return new NotificationGraphIterator(em, source.refIterator(em, true), query); } } catch ( Exception e ) { throw new RuntimeException( e ); } }
@Override public UUID createApplication( String organizationName, String applicationName ) throws Exception { Entity appInfo = emf.createApplicationV2(organizationName, applicationName); UUID applicationId = appInfo.getUuid(); return applicationId; }
private void deleteCreds( UUID appId, EntityRef owner, String key ) throws Exception { EntityManager em = emf.getEntityManager( appId ); em.removeFromDictionary(owner, DICTIONARY_CREDENTIALS, key); }
@Override public boolean newAppUsersRequireConfirmation( UUID applicationId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); Boolean registration_requires_email_confirmation = ( Boolean ) em .getProperty( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), REGISTRATION_REQUIRES_EMAIL_CONFIRMATION ); return registration_requires_email_confirmation != null && registration_requires_email_confirmation; }
public void confirmAppUser( UUID applicationId, UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); em.setProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "confirmed", true ); }
public User getUserEntityByIdentifier( UUID applicationId, Identifier identifier ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); return em.get(em.getUserByIdentifier(identifier), User.class); }
public UUID createApplication( String organizationName, String applicationName ) throws Exception { Entity appInfo = emf.createApplicationV2(organizationName, applicationName); UUID appId = appInfo.getUuid(); return appId; }
public boolean notifyAdminOfNewAppUsers( UUID applicationId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); Boolean notify_admin_of_new_users = ( Boolean ) em .getProperty( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), NOTIFY_ADMIN_OF_NEW_USERS ); return notify_admin_of_new_users != null && notify_admin_of_new_users; }