Package com.opengamma.engine.marketdata

Examples of com.opengamma.engine.marketdata.MarketDataPermissionProvider


  @Test
  public void permissionProvider() {
    MarketDataProvider historicalProvider1 = mock(MarketDataProvider.class);
    MarketDataProvider historicalProvider2 = mock(MarketDataProvider.class);
    MarketDataProvider baseProvider = mock(MarketDataProvider.class);
    MarketDataPermissionProvider pp1 = mock(MarketDataPermissionProvider.class);
    MarketDataPermissionProvider pp2 = mock(MarketDataPermissionProvider.class);
    MarketDataPermissionProvider pp3 = mock(MarketDataPermissionProvider.class);
    when(historicalProvider1.getPermissionProvider()).thenReturn(pp1);
    when(historicalProvider2.getPermissionProvider()).thenReturn(pp2);
    when(baseProvider.getPermissionProvider()).thenReturn(pp3);
    Set<ValueSpecification> specs = ImmutableSet.of(SPEC1, SPEC2, SPEC3, SPEC4);
    when(pp1.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC1));
    when(pp2.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC2));
    when(pp3.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC3));
    HistoricalShockMarketDataProvider provider =
        new HistoricalShockMarketDataProvider(historicalProvider1, historicalProvider2, baseProvider);
    assertEquals(ImmutableSet.of(SPEC1, SPEC2, SPEC3),
                 provider.getPermissionProvider().checkMarketDataPermissions(UserPrincipal.getTestUser(), specs));
  }
View Full Code Here


    @Override
    public Set<ValueSpecification> checkMarketDataPermissions(final UserPrincipal user, final Set<ValueSpecification> specifications) {
      final List<Set<ValueSpecification>> specsByProvider = partitionSpecificationsByProvider(_providers.size(), specifications);
      final Set<ValueSpecification> missingSpecifications = Sets.newHashSet();
      for (int i = 0; i < _providers.size(); i++) {
        final MarketDataPermissionProvider permissionProvider = _providers.get(i).getPermissionProvider();
        final Set<ValueSpecification> specsForProvider = specsByProvider.get(i);
        final Set<ValueSpecification> missing = permissionProvider.checkMarketDataPermissions(user, specsForProvider);
        if (!missing.isEmpty()) {
          for (final ValueSpecification specification : missing) {
            missingSpecifications.add(convertUnderlyingSpecification(i, specification));
          }
        }
View Full Code Here

  @Override
  public void viewDefinitionCompiled(final ViewExecutionDataProvider dataProvider, final CompiledViewDefinitionWithGraphs compiledViewDefinition) {
    // Caller MUST NOT hold the semaphore
    final ViewResultListener[] listeners;
    final MarketDataPermissionProvider permissionProvider = dataProvider.getPermissionProvider();
    lock();
    try {
      _latestCompiledViewDefinition.set(Pair.of(compiledViewDefinition, permissionProvider));
      listeners = getListenerArray();
    } finally {
      unlock();
    }
    final Set<ValueSpecification> marketData = compiledViewDefinition.getMarketDataRequirements();
    // [PLAT-1158] The notifications are performed outside of holding the lock which avoids the deadlock problem, but we'll still block
    // for completion which was the thing PLAT-1158 was trying to avoid. This is because the contracts for the order in which
    // notifications can be received is unclear and I don't want to risk introducing a change at this moment in time.
    for (final ViewResultListener listener : listeners) {
      try {
        final UserPrincipal listenerUser = listener.getUser();
        final boolean hasMarketDataPermissions = permissionProvider.checkMarketDataPermissions(listenerUser, marketData).isEmpty();
        listener.viewDefinitionCompiled(compiledViewDefinition, hasMarketDataPermissions);
      } catch (final Exception e) {
        logListenerError(listener, e);
      }
    }
View Full Code Here

      // [PLAT-1158] The initial notification is performed outside of holding the lock which avoids the deadlock problem, but we'll still
      // block for completion which was the thing PLAT-1158 was trying to avoid. This is because the contracts for the order in which
      // notifications can be received is unclear and I don't want to risk introducing a change at this moment in time.
      try {
        final CompiledViewDefinitionWithGraphs compiledViewDefinition = latestCompilation.getFirst();
        final MarketDataPermissionProvider permissionProvider = latestCompilation.getSecond();
        final Set<ValueSpecification> marketData = compiledViewDefinition.getMarketDataRequirements();
        final Set<ValueSpecification> deniedRequirements =
            permissionProvider.checkMarketDataPermissions(listener.getUser(), marketData);
        final boolean hasMarketDataPermissions = deniedRequirements.isEmpty();
        listener.viewDefinitionCompiled(compiledViewDefinition, hasMarketDataPermissions);
        if (latestResult != null) {
          listener.cycleCompleted(latestResult, null);
        }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.marketdata.MarketDataPermissionProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.