Exemple #1
0
  private WizardStepPanel setupWizardFlow() {
    // get the consent mode variable value
    EnumSet<ConsentMode> supportedConsentMode = consentService.getSupportedConsentModes();
    List<Locale> supportedConsentLocale = consentService.getSupportedConsentLocales();
    WizardStepPanel startStep;

    if (supportedConsentMode.containsAll(EnumSet.allOf(ConsentMode.class))
        || supportedConsentMode.contains(ConsentMode.MANUAL) && supportedConsentLocale.size() > 1) {
      startStep = consentModeSelectionStep;
      startStep.setPreviousStep(startStep);
      electronicConsentStep.setPreviousStep(startStep);
    } else {
      consentConfirmationStep.setPreviousStep(null);
      startStep = consentConfirmationStep;
    }

    return startStep;
  }
Exemple #2
0
  /**
   * Grants a new permission for a given subject and resource.
   *
   * @param subjectid the subject to give permissions to
   * @param resourceName the resource name/type
   * @param permission the set or HTTP methods allowed
   * @return true if successful
   */
  public boolean grantResourcePermission(
      String subjectid, String resourceName, EnumSet<AllowedMethods> permission) {
    // clean up resource name
    resourceName = Utils.noSpaces(resourceName, "-");

    if (!StringUtils.isBlank(subjectid)
        && !StringUtils.isBlank(resourceName)
        && permission != null
        && !permission.isEmpty()) {
      if (!getResourcePermissions().containsKey(subjectid)) {
        Map<String, List<String>> perm = new HashMap<String, List<String>>();
        perm.put(resourceName, new ArrayList<String>(permission.size()));
        for (AllowedMethods allowedMethod : permission) {
          perm.get(resourceName).add(allowedMethod.toString());
        }
        getResourcePermissions().put(subjectid, perm);
      } else {
        if (permission.containsAll(AllowedMethods.ALL_VALUES)
            || permission.contains(AllowedMethods.READ_WRITE)
            || (permission.contains(AllowedMethods.READ_ONLY)
                && permission.contains(AllowedMethods.WRITE_ONLY))
            || (permission.contains(AllowedMethods.GET)
                && permission.contains(AllowedMethods.WRITE_ONLY))) {
          permission = AllowedMethods.READ_AND_WRITE;
        } else {
          if (permission.contains(AllowedMethods.WRITE_ONLY)) {
            permission = AllowedMethods.WRITE;
          } else if (permission.contains(AllowedMethods.READ_ONLY)) {
            permission = AllowedMethods.READ;
          }
        }
        List<String> perm = new ArrayList<String>(permission.size());
        for (AllowedMethods allowedMethod : permission) {
          perm.add(allowedMethod.toString());
        }
        getResourcePermissions().get(subjectid).put(resourceName, perm);
      }
      return true;
    }
    return false;
  }
Exemple #3
0
  /**
   * Select the technique to use for rendering this material.
   *
   * <p>If <code>name</code> is "Default", then one of the {@link MaterialDef#getDefaultTechniques()
   * default techniques} on the material will be selected. Otherwise, the named technique will be
   * found in the material definition.
   *
   * <p>Any candidate technique for selection (either default or named) must be verified to be
   * compatible with the system, for that, the <code>renderManager</code> is queried for
   * capabilities.
   *
   * @param name The name of the technique to select, pass "Default" to select one of the default
   *     techniques.
   * @param renderManager The {@link RenderManager render manager} to query for capabilities.
   * @throws IllegalArgumentException If "Default" is passed and no default techniques are available
   *     on the material definition, or if a name is passed but there's no technique by that name.
   * @throws UnsupportedOperationException If no candidate technique supports the system
   *     capabilities.
   */
  public void selectTechnique(String name, RenderManager renderManager) {
    // check if already created
    Technique tech = techniques.get(name);
    // When choosing technique, we choose one that
    // supports all the caps.
    EnumSet<Caps> rendererCaps = renderManager.getRenderer().getCaps();
    if (tech == null) {

      if (name.equals("Default")) {
        List<TechniqueDef> techDefs = def.getDefaultTechniques();
        if (techDefs == null || techDefs.isEmpty()) {
          throw new IllegalArgumentException(
              "No default techniques are available on material '" + def.getName() + "'");
        }

        TechniqueDef lastTech = null;
        for (TechniqueDef techDef : techDefs) {
          if (rendererCaps.containsAll(techDef.getRequiredCaps())) {
            // use the first one that supports all the caps
            tech = new Technique(this, techDef);
            techniques.put(name, tech);
            break;
          }
          lastTech = techDef;
        }
        if (tech == null) {
          throw new UnsupportedOperationException(
              "No default technique on material '"
                  + def.getName()
                  + "'\n"
                  + " is supported by the video hardware. The caps "
                  + lastTech.getRequiredCaps()
                  + " are required.");
        }

      } else {
        // create "special" technique instance
        TechniqueDef techDef = def.getTechniqueDef(name);
        if (techDef == null) {
          throw new IllegalArgumentException(
              "For material " + def.getName() + ", technique not found: " + name);
        }

        if (!rendererCaps.containsAll(techDef.getRequiredCaps())) {
          throw new UnsupportedOperationException(
              "The explicitly chosen technique '"
                  + name
                  + "' on material '"
                  + def.getName()
                  + "'\n"
                  + "requires caps "
                  + techDef.getRequiredCaps()
                  + " which are not "
                  + "supported by the video renderer");
        }

        tech = new Technique(this, techDef);
        techniques.put(name, tech);
      }
    } else if (technique == tech) {
      // attempting to switch to an already
      // active technique.
      return;
    }

    technique = tech;
    tech.makeCurrent(def.getAssetManager(), true, rendererCaps);

    // shader was changed
    sortingId = -1;
  }
Exemple #4
0
  /**
   * Creates a list of detectors applicable to the given cope, and with the given configuration.
   *
   * @param client the client to report errors to
   * @param configuration the configuration to look up which issues are enabled etc from
   * @param scope the scope for the analysis, to filter out detectors that require wider analysis
   *     than is currently being performed
   * @param scopeToDetectors an optional map which (if not null) will be filled by this method to
   *     contain mappings from each scope to the applicable detectors for that scope
   * @return a list of new detector instances
   */
  @NonNull
  final List<? extends Detector> createDetectors(
      @NonNull LintClient client,
      @NonNull Configuration configuration,
      @NonNull EnumSet<Scope> scope,
      @Nullable Map<Scope, List<Detector>> scopeToDetectors) {
    List<Issue> issues = getIssues();
    Set<Class<? extends Detector>> detectorClasses = new HashSet<Class<? extends Detector>>();
    Map<Class<? extends Detector>, EnumSet<Scope>> detectorToScope =
        new HashMap<Class<? extends Detector>, EnumSet<Scope>>();
    for (Issue issue : issues) {
      Class<? extends Detector> detectorClass = issue.getDetectorClass();
      EnumSet<Scope> issueScope = issue.getScope();
      if (!detectorClasses.contains(detectorClass)) {
        // Determine if the issue is enabled
        if (!configuration.isEnabled(issue)) {
          continue;
        }

        // Determine if the scope matches
        if (!issue.isAdequate(scope)) {
          continue;
        }

        detectorClass = client.replaceDetector(detectorClass);

        assert detectorClass != null : issue.getId();
        detectorClasses.add(detectorClass);
      }

      if (scopeToDetectors != null) {
        EnumSet<Scope> s = detectorToScope.get(detectorClass);
        if (s == null) {
          detectorToScope.put(detectorClass, issueScope);
        } else if (!s.containsAll(issueScope)) {
          EnumSet<Scope> union = EnumSet.copyOf(s);
          union.addAll(issueScope);
          detectorToScope.put(detectorClass, union);
        }
      }
    }

    List<Detector> detectors = new ArrayList<Detector>(detectorClasses.size());
    for (Class<? extends Detector> clz : detectorClasses) {
      try {
        Detector detector = clz.newInstance();
        detectors.add(detector);

        if (scopeToDetectors != null) {
          EnumSet<Scope> union = detectorToScope.get(clz);
          for (Scope s : union) {
            List<Detector> list = scopeToDetectors.get(s);
            if (list == null) {
              list = new ArrayList<Detector>();
              scopeToDetectors.put(s, list);
            }
            list.add(detector);
          }
        }
      } catch (Throwable t) {
        client.log(t, "Can't initialize detector %1$s", clz.getName()); // $NON-NLS-1$
      }
    }

    return detectors;
  }