private String getProviderId(EntityRef device, Notifier notifier) throws Exception { try { Object value = em.getProperty(device, notifier.getName() + NOTIFIER_ID_POSTFIX); if (value == null) { value = em.getProperty(device, notifier.getUuid() + NOTIFIER_ID_POSTFIX); } return value != null ? value.toString() : null; } catch (Exception e) { logger.error("Error getting notifier for device {}, proceeding with rest of batch", device, e); return null; } }
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; }
@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 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; }
@Override public boolean isAdminUserActivated( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "activated" ) ); }
@Override public boolean isAdminUserEnabled( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return !Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "disabled" ) ); }
@Override public boolean isOrganizationActivated( UUID organizationId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "activated" ) ); }
@Override public ServiceResults getEntityDictionary( ServiceContext context, List<EntityRef> refs, EntityDictionaryEntry dictionary ) throws Exception { if ( "permissions".equalsIgnoreCase( dictionary.getName() ) ) { EntityRef ref = refs.get( 0 ); checkPermissionsForEntitySubPath( context, ref, "/permissions" ); String roleName = ( String ) em.getProperty( ref, "name" ); //Should never happen if ( isBlank( roleName ) ) { throw new IllegalArgumentException( "You must provide a role name" ); } return getApplicationRolePermissions( roleName ); } return super.getEntityDictionary( context, refs, dictionary ); }
@Override public boolean isAdminUserConfirmed( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "confirmed" ) ); }
@Override public boolean isOrganizationEnabled( UUID organizationId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return !Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "disabled" ) ); }
@Override public ServiceResults postEntityDictionary( ServiceContext context, List<EntityRef> refs, EntityDictionaryEntry dictionary, ServicePayload payload ) throws Exception { if ( "permissions".equalsIgnoreCase( dictionary.getName() ) ) { EntityRef ref = refs.get( 0 ); checkPermissionsForEntitySubPath( context, ref, "/permissions" ); String roleName = ( String ) em.getProperty( ref, "name" ); if ( isBlank( roleName ) ) { throw new IllegalArgumentException( String.format( "Could not load role with id '%s'", ref.getUuid() ) ); } String permission = payload.getStringProperty( "permission" ); if ( isBlank( permission ) ) { throw new IllegalArgumentException( "You must supply a 'permission' property" ); } return grantApplicationRolePermission( roleName, permission ); } return super.postEntityDictionary( context, refs, dictionary, payload ); }
private void replaceProviderId(EntityRef device, Notifier notifier, String newProviderId) throws Exception { Object value = em.getProperty(device, notifier.getName() + ApplicationQueueManager.NOTIFIER_ID_POSTFIX); if (value != null) { em.setProperty(device, notifier.getName() + ApplicationQueueManager.NOTIFIER_ID_POSTFIX, newProviderId); } else { value = em.getProperty(device, notifier.getUuid() + ApplicationQueueManager.NOTIFIER_ID_POSTFIX); if (value != null) { em.setProperty(device, notifier.getUuid() + ApplicationQueueManager.NOTIFIER_ID_POSTFIX, newProviderId); } } }
@Override public ServiceResults deleteEntityDictionary( ServiceContext context, List<EntityRef> refs, EntityDictionaryEntry dictionary ) throws Exception { if ( "permissions".equalsIgnoreCase( dictionary.getName() ) ) { EntityRef ref = refs.get( 0 ); checkPermissionsForEntitySubPath( context, ref, "/permissions" ); String roleName = ( String ) em.getProperty( ref, "name" ); if ( isBlank( roleName ) ) { throw new IllegalArgumentException( String.format( "Could not load role with id '%s'", ref.getUuid() ) ); } Query q = null; if ( context.getParameters().size() > 0 ) { q = context.getParameters().get( 0 ).getQuery(); } if ( q == null ) { throw new IllegalArgumentException( "You must supply a 'permission' query parameter" ); } List<String> permissions = q.getPermissions(); if ( permissions == null ) { throw new IllegalArgumentException( "You must supply a 'permission' query parameter" ); } ServiceResults results = null; for ( String permission : permissions ) { results = revokeApplicationRolePermission( roleName, permission ); } return results; } return super.deleteEntityDictionary( context, refs, dictionary ); }
String appName = ( String ) em.getProperty( em.getApplicationRef(), "name" ); applicationSet.put( applicationId, appName ); application = new ApplicationInfo( applicationId, appName );
String appName = ( String ) em.getProperty( em.getApplicationRef(), "name" ); applicationSet.put( applicationId, appName ); application = new ApplicationInfo( applicationId, appName );