public ServiceResults deleteGroupRole( UUID groupId, String roleName ) throws Exception { em.removeGroupFromRole( groupId, roleName ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); return getGroupRoles( groupId ); }
public ServiceResults grantApplicationRolePermission( String roleName, String permission ) throws Exception { em.grantRolePermission(roleName, permission); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); return getApplicationRolePermissions( roleName ); }
public ServiceResults addGroupRole( UUID groupId, String roleName ) throws Exception { em.addGroupToRole( groupId, roleName ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); return getGroupRoles( groupId ); }
public ServiceResults revokeApplicationRolePermission( String roleName, String permission ) throws Exception { em.revokeRolePermission( roleName, permission ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); return getApplicationRolePermissions( roleName ); }
@Override public ServiceResults postEntityDictionary( ServiceContext context, List<EntityRef> refs, EntityDictionaryEntry dictionary, ServicePayload payload ) throws Exception { if ( "permissions".equalsIgnoreCase( dictionary.getName() ) ) { EntityRef entityRef = refs.get( 0 ); checkPermissionsForEntitySubPath( context, entityRef, "permissions" ); String permission = payload.getStringProperty( "permission" ); if ( isBlank( permission ) ) { return null; } em.grantUserPermission( entityRef.getUuid(), permission ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); return genericServiceResults().withData( em.getUserPermissions( entityRef.getUuid() ) ); } return super.postEntityDictionary( context, refs, dictionary, payload ); }
@Override public ServiceResults postEntityDictionary( ServiceContext context, List<EntityRef> refs, EntityDictionaryEntry dictionary, ServicePayload payload ) throws Exception { if ( "permissions".equalsIgnoreCase( dictionary.getName() ) ) { EntityRef entityRef = refs.get( 0 ); checkPermissionsForEntitySubPath( context, entityRef, "permissions" ); String permission = payload.getStringProperty( "permission" ); if ( isBlank( permission ) ) { return null; } em.grantGroupPermission( entityRef.getUuid(), permission ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); return genericServiceResults().withData( em.getGroupPermissions( entityRef.getUuid() ) ); } return super.postEntityDictionary( context, refs, dictionary, payload ); }
ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll();
em.revokeGroupPermission( entityRef.getUuid(), permission ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll();
@Override public ServiceResults deleteItemById( ServiceContext context, UUID id ) throws Exception { User user = em.get( context.getOwner(), User.class ); ServiceResults results = getItemById( context, id ); if ( !results.isEmpty() ) { em.removeUserFromRole( user.getUuid(), results.getEntity().getName() ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); } return results; }
@Override public ServiceResults deleteItemByName( ServiceContext context, String name ) throws Exception { User user = em.get( context.getOwner(), User.class ); ServiceResults results = getItemByName( context, name ); if ( !results.isEmpty() ) { em.removeUserFromRole( user.getUuid(), results.getEntity().getName() ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); } return results; } }
@Override public ServiceResults postItemById( ServiceContext context, UUID id ) throws Exception { User user = em.get( context.getOwner(), User.class ); Entity entity = sm.getService( "/roles" ).getEntity( context.getRequest(), id ); if ( entity != null ) { em.addUserToRole( user.getUuid(), entity.getName() ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); } return new ServiceResults( this, context, Type.COLLECTION, Results.fromRef( entity ), null, null ); }
@Override public ServiceResults postItemByName( ServiceContext context, String name ) throws Exception { User user = em.get( context.getOwner(), User.class ); Entity entity = sm.getService( "/roles" ).getEntity( context.getRequest(), name ); if ( entity != null ) { em.addUserToRole( user.getUuid(), entity.getName() ); ScopedCache scopedCache = cacheFactory.getScopedCache(new CacheScope(em.getApplication().asId())); scopedCache.invalidate(); localShiroCache.invalidateAll(); } return new ServiceResults( this, context, Type.COLLECTION, Results.fromRef( entity ), null, null ); }