public static void startServer(Class<? extends Filter> filter) throws Exception {
    _tester = new ServletTester("/ctx");
    HttpURI uri = new HttpURI(_tester.createConnector(true));
    _host = uri.getHost();
    _port = uri.getPort();

    _tester.getContext().addServlet(TestServlet.class, "/*");

    _dosFilter =
        _tester.getContext().addFilter(filter, "/dos/*", EnumSet.allOf(DispatcherType.class));
    _dosFilter.setInitParameter("maxRequestsPerSec", "4");
    _dosFilter.setInitParameter("delayMs", "200");
    _dosFilter.setInitParameter("throttledRequests", "1");
    _dosFilter.setInitParameter("waitMs", "10");
    _dosFilter.setInitParameter("throttleMs", "4000");
    _dosFilter.setInitParameter("remotePort", "false");
    _dosFilter.setInitParameter("insertHeaders", "true");

    _timeoutFilter =
        _tester.getContext().addFilter(filter, "/timeout/*", EnumSet.allOf(DispatcherType.class));
    _timeoutFilter.setInitParameter("maxRequestsPerSec", "4");
    _timeoutFilter.setInitParameter("delayMs", "200");
    _timeoutFilter.setInitParameter("throttledRequests", "1");
    _timeoutFilter.setInitParameter("waitMs", "10");
    _timeoutFilter.setInitParameter("throttleMs", "4000");
    _timeoutFilter.setInitParameter("remotePort", "false");
    _timeoutFilter.setInitParameter("insertHeaders", "true");
    _timeoutFilter.setInitParameter("maxRequestMs", _requestMaxTime + "");

    _tester.start();
  }
Esempio n. 2
0
 public Filter() {
   minCost = 0;
   maxCost = MasterDeck.getHighestCardCost();
   attributes = EnumSet.noneOf(Attribute.class);
   colors = EnumSet.allOf(ColorFlag.class);
   cardTypes = EnumSet.allOf(CardType.class);
   cardTypes.remove(CardType.CHAMPION);
   cardSets = EnumSet.allOf(CardSet.class);
 }
 public final void testGetThe1000Articles() throws CoreException {
   AggregatorItem folder = getCollection().getChildAt(EnumSet.allOf(ItemType.class), 0);
   System.out.println(folder);
   for (int a = 0; a < 1000; a++) {
     AggregatorItem item = ((Folder) folder).getChildAt(EnumSet.allOf(ItemType.class), 0);
     System.out.println(item);
     if (item == null) fail("Retrieved item is null"); // $NON-NLS-1$
   }
 }
  private void initializeLeftPanel(
      @NotNull final PanelState panelState,
      @NotNull Provider<TabBuilder> tabBuilderProvider,
      @NotNull HistoryPanel historyPanel,
      @NotNull final TemplatesContainer templatesContainer) {
    TabSelectHandler historyHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            selectHistoryTab();
          }
        };

    Tab historyTab =
        tabBuilderProvider
            .get()
            .presenter(historyPanel)
            .selectHandler(historyHandler)
            .title(locale.runnerTabHistory())
            .visible(REMOVABLE)
            .scope(EnumSet.allOf(State.class))
            .tabType(LEFT)
            .build();

    leftTabContainer.addTab(historyTab);

    TabSelectHandler templatesHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            state = TEMPLATE;
            panelState.setState(State.TEMPLATE);

            templatesContainer.selectEnvironment();
            templatesContainer.changeEnableStateRunButton();

            view.hideOtherButtons();
          }
        };

    Tab templateTab =
        tabBuilderProvider
            .get()
            .presenter(templatesContainer)
            .selectHandler(templatesHandler)
            .title(locale.runnerTabTemplates())
            .visible(REMOVABLE)
            .scope(EnumSet.allOf(State.class))
            .tabType(LEFT)
            .build();

    leftTabContainer.addTab(templateTab);
  }
  static {
    SYMBOL_ID_MAP = new HashMap<Short, TemplateTokenType>();

    for (TemplateTokenType type : EnumSet.allOf(TemplateTokenType.class)) {
      SYMBOL_ID_MAP.put(type.getIndex(), type);
    }

    TREE_SYMBOL_ID_MAP = new HashMap<Short, TemplateTokenType>();

    for (TemplateTokenType type : EnumSet.allOf(TemplateTokenType.class)) {
      TREE_SYMBOL_ID_MAP.put(type.getTreeIndex(), type);
    }
  }
 /**
  * Assumes that the folder item created in the previous method still exists and attempts to delete
  * it. Fails if the item did not exist and if it still exists after deleting it.
  *
  * @throws CoreException
  */
 public final void testDeleteFolder() throws CoreException {
   AggregatorCollection collection = getCollection();
   // Assume the folder was added in the method above
   AggregatorItem item = collection.getChildAt(EnumSet.allOf(ItemType.class), 0);
   if (item == null) {
     fail("Folder item could not be retrieved"); // $NON-NLS-1$
   }
   item.getParent().trash(item);
   item = collection.getChildAt(EnumSet.allOf(ItemType.class), 0);
   if (item != null) {
     fail("Folder item was not deleted"); // $NON-NLS-1$
   }
 }
Esempio n. 7
0
  public static MimeType get(String typeOrExtension) {
    for (MimeType m : EnumSet.allOf(MimeType.class)) {
      if (m.getType().equalsIgnoreCase(typeOrExtension)
          || m.getExtension().equalsIgnoreCase(typeOrExtension)) {
        return m;
      }
    }

    return MimeType.PNG;

    /*Iterator it = lookup.entrySet().iterator();
    while (it.hasNext()) {
    	Map.Entry pair = (Map.Entry)it.next();
    	if
    }

    // Check first if we give in the name of the mime, like svg, png, pfd
    MimeType mime = MimeType.valueOf(type.toUpperCase());
    if (mime != null) {
    	return mime;
    }

    // if not matched above, check if we can lookup the mime based on the content-type
    mime = lookup.get(type);
    if (mime != null) {
    	return mime;
    }
    // else return default
    return MimeType.PNG;*/
  }
  static {
    lookup = new HashMap<>();

    for (WdMailMergeMainDocType e : EnumSet.allOf(WdMailMergeMainDocType.class)) {
      lookup.put(e.value(), e);
    }
  }
Esempio n. 9
0
  /**
   * Gets localization bundle.
   *
   * @param bundleNames name of bundle. If {@code null} all bundles are included.
   * @param locale optional locale. If {@code null} HTTP headers are queried for acceptable language
   * @param sorted optional flag to partially sort result bundle items by value. Default is {@code
   *     true}.
   * @return the bundle
   */
  @GET
  @Produces({MediaType.APPLICATION_JSON})
  public SmartGwtResponse<Item> getBundle(
      @QueryParam(LocalizationResourceApi.ITEM_BUNDLENAME) Set<BundleName> bundleNames,
      @DefaultValue("") @QueryParam(LocalizationResourceApi.GETBUNDLE_LOCALE_PARAM) String locale,
      @DefaultValue("true") @QueryParam(LocalizationResourceApi.GETBUNDLE_SORTED_PARAM)
          boolean sorted) {

    if (bundleNames == null || bundleNames.isEmpty()) {
      bundleNames = EnumSet.allOf(BundleName.class);
    }
    Locale localeObj;
    if (locale == null || locale.isEmpty()) {
      List<Locale> acceptableLanguages = httpHeaders.getAcceptableLanguages();
      localeObj = acceptableLanguages.isEmpty() ? Locale.ENGLISH : acceptableLanguages.get(0);
    } else {
      localeObj = new Locale(locale);
    }

    Control control = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_PROPERTIES);
    ArrayList<Item> result = new ArrayList<Item>();
    for (BundleName bundleName : bundleNames) {
      try {
        if (!BundleName.PROPERTIES.equals(bundleName.getFormat())) {
          continue;
        }
        result.addAll(readBundle(bundleName, localeObj, control, sorted));
      } catch (MissingResourceException ex) {
        LOG.log(Level.WARNING, bundleNames.toString(), ex);
        throw RestException.plainNotFound(
            LocalizationResourceApi.ITEM_BUNDLENAME, bundleName.toString());
      }
    }
    return new SmartGwtResponse<Item>(result);
  }
Esempio n. 10
0
public enum FieldProperty {
  YES_NO,
  DATE,
  JOURNAL_NAME,
  EXTERNAL,
  OWNER,
  MONTH,
  FILE_EDITOR,
  NUMERIC,
  PERSON_NAMES,
  INTEGER,
  GENDER,
  LANGUAGE,
  DOI,
  EDITOR_TYPE,
  PAGINATION,
  TYPE,
  CROSSREF,
  ISO_DATE,
  ISBN,
  EPRINT,
  BOOK_NAME,
  SINGLE_ENTRY_LINK,
  MULTIPLE_ENTRY_LINK,
  PUBLICATION_STATE,
  VERBATIM;

  public static final Set<FieldProperty> ALL_OPTS = EnumSet.allOf(FieldProperty.class);
}
Esempio n. 11
0
  public static ActMood valueOf(ST code) {
    // set up the _codeMap if needed for the first time
    if (_codeMap == null) {
      synchronized (ActMood.class) { // that one time might just as well keep it thread-safe
        if (_codeMap == null) {
          _codeMap = new HashMap();
          for (ActMood concept : EnumSet.allOf(ActMood.class)) {
            ST conceptCode = concept.code();
            if (conceptCode != null && conceptCode.nonNull().isTrue()) {
              _codeMap.put(conceptCode, concept);
            }
          }
        }
      }
    }

    if (code.nonNull().isTrue()) {
      ActMood concept = _codeMap.get(code);
      if (concept == null)
        throw new IllegalArgumentException(
            ("unknown code "
                + code
                + " at codeSystem = "
                + "2.16.840.1.113883.5.1001"
                + ", domain = "
                + "ActMood"));
      else return concept;
    } else return null;
  }
Esempio n. 12
0
  static {
    lookup = new HashMap<>();

    for (WdFindMatch e : EnumSet.allOf(WdFindMatch.class)) {
      lookup.put(e.value(), e);
    }
  }
Esempio n. 13
0
  /** @return the file filters which can be used to load a file */
  public static FileFilter[] getLoadingFilters() {
    Collection<XcosFileType> used = EnumSet.allOf(XcosFileType.class);
    Iterator<XcosFileType> it = used.iterator();

    final FileFilter[] filters = new FileFilter[used.size() + 1];

    final String[] extensions = new String[used.size()];
    final String[] descriptions = new String[used.size()];
    for (int i = 0; i < extensions.length; i++) {
      final XcosFileType type = it.next();

      descriptions[i] = type.getDescription();
      extensions[i] = type.getExtension();
    }

    /*
     * One file filter for all valid extensions
     */
    filters[0] = new FileNameExtensionFilter(XcosMessages.ALL_SUPPORTED_FORMATS, extensions);

    /*
     * Then one file filter per enum value.
     */
    for (int i = 0; i < descriptions.length; i++) {
      filters[i + 1] = new FileNameExtensionFilter(descriptions[i], extensions[i]);
    }

    return filters;
  }
Esempio n. 14
0
    protected CompleteReferenceProcessor() {
      super(null, EnumSet.allOf(ResolveKind.class), myRefExpr, PsiType.EMPTY_ARRAY);
      myConsumer =
          new Consumer<LookupElement>() {
            @Override
            public void consume(LookupElement element) {
              myIsEmpty = false;
              CompleteReferenceExpression.this.myConsumer.consume(element);
            }
          };
      myPreferredFieldNames = addAllRestrictedProperties();
      mySkipPackages = shouldSkipPackages();
      myEventListener =
          JavaPsiFacade.getInstance(myRefExpr.getProject())
              .findClass("java.util.EventListener", myRefExpr.getResolveScope());
      myPropertyNames.addAll(myPreferredFieldNames);

      myFieldPointerOperator = myRefExpr.hasAt();
      myMethodPointerOperator = myRefExpr.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER;
      myIsMap = isMap();
      final PsiType thisType = GrReferenceResolveUtil.getQualifierType(myRefExpr);
      mySubstitutorComputer =
          new SubstitutorComputer(
              thisType, PsiType.EMPTY_ARRAY, PsiType.EMPTY_ARRAY, myRefExpr, myRefExpr.getParent());
    }
  static {
    lookup = new HashMap<>();

    for (MsoBlogCategorySupport e : EnumSet.allOf(MsoBlogCategorySupport.class)) {
      lookup.put(e.value(), e);
    }
  }
 static {
   int value = 0;
   for (ResourceField e : EnumSet.allOf(ResourceField.class)) {
     e.m_value = value++;
     TYPE_VALUES[e.getValue()] = e;
   }
 }
 public final void testAddArticle() throws CoreException {
   AggregatorCollection collection = getCollection();
   // Create the feed
   Subscription feed = TestUtils.createNewFeed("Feed title"); // $NON-NLS-1$
   // This should also add a new folder automatically as we did not specify
   // the location for the feed.
   Folder folder = collection.addNew(feed);
   // Create the article
   Article article_a =
       new Article((AggregatorItemParent) folder, UUID.randomUUID(), feed.getUUID());
   article_a.setGuid("myGUID"); // $NON-NLS-1$
   // Add it to the collection
   collection.addNew(new Article[] {article_a});
   // See that it's there (at position 0 in the folder)
   AggregatorItem item = folder.getChildAt(EnumSet.allOf(ItemType.class), 0);
   if (item == null) {
     fail("Article item could not be retrieved"); // $NON-NLS-1$
   }
   // And that the item is a folder
   if (!(item instanceof Article)) {
     fail("Returned item is not article"); // $NON-NLS-1$
   }
   Article folder_b = (Article) item;
   // Compare the basics
   compareAggregatorItems(article_a, folder_b);
 }
Esempio n. 18
0
  static {
    lookup = new HashMap<>();

    for (WdTextureIndex e : EnumSet.allOf(WdTextureIndex.class)) {
      lookup.put(e.value(), e);
    }
  }
 private ArchiveApplicationEntity createAdminAE(
     String aet,
     String[] image_tsuids,
     String[] video_tsuids,
     String[] other_tsuids,
     String pixConsumer,
     String pixManager) {
   ArchiveApplicationEntity ae = new ArchiveApplicationEntity(aet);
   ae.setAssociationAcceptor(true);
   ae.setAssociationInitiator(true);
   ae.setMatchUnknown(true);
   ae.setSendPendingCGet(true);
   ae.setSendPendingCMoveInterval(PENDING_CMOVE_INTERVAL);
   ae.addRejectionNote(INCORRECT_WORKLIST_ENTRY_SELECTED);
   ae.addRejectionNote(REJECT_FOR_PATIENT_SAFETY_REASONS);
   ae.addRejectionNote(INCORRECT_MODALITY_WORKLIST_ENTRY);
   ae.addRejectionNote(DATA_RETENTION_PERIOD_EXPIRED);
   addTCs(ae, null, SCU, IMAGE_CUIDS, image_tsuids);
   addTCs(ae, null, SCU, VIDEO_CUIDS, video_tsuids);
   addTCs(ae, null, SCU, OTHER_CUIDS, other_tsuids);
   addTCs(ae, EnumSet.allOf(QueryOption.class), SCP, QUERY_CUIDS, UID.ImplicitVRLittleEndian);
   addTCs(ae, EnumSet.of(QueryOption.RELATIONAL), SCP, RETRIEVE_CUIDS, UID.ImplicitVRLittleEndian);
   addTC(
       ae, null, SCP, UID.CompositeInstanceRetrieveWithoutBulkDataGET, UID.ImplicitVRLittleEndian);
   addTC(ae, null, SCP, UID.VerificationSOPClass, UID.ImplicitVRLittleEndian);
   addTC(ae, null, SCU, UID.VerificationSOPClass, UID.ImplicitVRLittleEndian);
   ae.setReturnOtherPatientIDs(true);
   ae.setReturnOtherPatientNames(true);
   ae.setLocalPIXConsumerApplication(pixConsumer);
   ae.setRemotePIXManagerApplication(pixManager);
   return ae;
 }
  static {
    lookup = new HashMap<>();

    for (WdDefaultTableBehavior e : EnumSet.allOf(WdDefaultTableBehavior.class)) {
      lookup.put(e.value(), e);
    }
  }
Esempio n. 21
0
  static {
    lookup = new HashMap<>();

    for (WdLayoutMode e : EnumSet.allOf(WdLayoutMode.class)) {
      lookup.put(e.value(), e);
    }
  }
Esempio n. 22
0
  static {
    opcodeMap = new HashMap<Integer, Opcode>();

    for (Opcode opcode : EnumSet.allOf(Opcode.class)) {
      opcodeMap.put(opcode.getOpcode(), opcode);
    }
  }
Esempio n. 23
0
 /**
  * Add the given permission to the permission set.
  *
  * @param permissions The permission set
  * @param toAdd The permissions to add
  * @return The same permission set as passed in
  */
 private static EnumSet<Permission> addPermission(
     EnumSet<Permission> permissions, Permission... toAdd) {
   for (Permission onePerm : toAdd) {
     // Permissions that infer other permissions need to be listed here and
     // set the inferred permissions as well as itself.
     //
     // Always add the permission itself and then call this method to add
     // the inferred permissions.
     switch (onePerm) {
       case ADMIN:
         permissions.addAll(EnumSet.allOf(Permission.class));
         break;
       case SQL:
         permissions.add(SQL);
         addPermission(permissions, SQLREAD, DEFAULTPROC);
         break;
       case SQLREAD:
         permissions.add(SQLREAD);
         addPermission(permissions, DEFAULTPROCREAD);
         break;
       case DEFAULTPROC:
         permissions.add(DEFAULTPROC);
         addPermission(permissions, DEFAULTPROCREAD);
       default:
         permissions.add(onePerm);
     }
   }
   return permissions;
 }
  public static enum Expansions {
    COUNT("count"),
    RATE_MEAN("meanRate"),
    RATE_1_MINUTE("1MinuteRate"),
    RATE_5_MINUTE("5MinuteRate"),
    RATE_15_MINUTE("15MinuteRate"),
    MIN("min"),
    MEAN("mean"),
    MAX("max"),
    STD_DEV("stddev"),
    MEDIAN("median"),
    P75("p75"),
    P95("p95"),
    P98("p98"),
    P99("p99"),
    P999("p999");

    public static EnumSet<Expansions> ALL = EnumSet.allOf(Expansions.class);

    private final String displayName;

    private Expansions(String displayName) {
      this.displayName = displayName;
    }

    @Override
    public String toString() {
      return displayName;
    }
  }
  /**
   * Setter for the property 'connectionTracingEvents'. This method is called by the container
   *
   * @param tracingSpec A comma delimited list of {@link HzConnectionEvent}
   */
  public void setConnectionTracingEvents(String tracingSpec) {
    if ((null != tracingSpec) && (0 < tracingSpec.length())) {
      List<HzConnectionEvent> traceEvents = new ArrayList<HzConnectionEvent>();

      for (String traceEventId : tracingSpec.split(",")) {
        traceEventId = traceEventId.trim();
        try {
          HzConnectionEvent traceEvent = HzConnectionEvent.valueOf(traceEventId);
          if (null != traceEvent) {
            traceEvents.add(traceEvent);
          }
        } catch (IllegalArgumentException iae) {
          log(
              Level.WARNING,
              "Ignoring illegal token \""
                  + traceEventId
                  + "\" from connection config-property "
                  + "connectionTracingEvents, valid tokens are "
                  + EnumSet.allOf(HzConnectionEvent.class));
        }
      }

      this.hzConnectionTracingEvents = EnumSet.copyOf(traceEvents);
    } else {
      this.hzConnectionTracingEvents = emptySet();
    }
  }
Esempio n. 26
0
  static {
    lookup = new HashMap<>();

    for (MsoColorType e : EnumSet.allOf(MsoColorType.class)) {
      lookup.put(e.value(), e);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void onToggleSplitterClicked(boolean isShowSplitter) {
    terminalTab.setScopes(isShowSplitter ? EnumSet.allOf(State.class) : EnumSet.of(RUNNERS));

    if (isShowSplitter) {
      panelState.setSplitterState(SPLITTER_ON);

      view.setLeftPropertiesPanel(leftPropertiesContainer);
      view.setRightPropertiesPanel(rightPropertiesContainer);
    } else {
      panelState.setSplitterState(SPLITTER_OFF);

      view.setGeneralPropertiesPanel(rightPropertiesContainer);
    }

    if (TEMPLATE.equals(state)) {
      panelState.setState(TEMPLATE);

      leftTabContainer.showTab(locale.runnerTabTemplates());

      if (SPLITTER_OFF.equals(panelState.getSplitterState())) {
        rightPropertiesContainer.showTab(propertiesTab.getTitle());
      }
    }
  }
  public RestTransportServer(RestContact contact, final AppServerHandler appServerHandler) {
    this.contact = contact;

    server = new Server(contact.getPort());
    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath("/");

    // servletContextHandler.addServlet(new ServletHolder(new
    // RestTransportServlet(appServerHandler)), "/*");
    servletContextHandler.addServlet(new ServletHolder(new NotFoundServlet()), "/*");

    final Injector injector =
        Guice.createInjector(
            new ReefyServletModule(),
            new AbstractModule() {
              @Override
              protected void configure() {
                binder().requireExplicitBindings();
                bind(GuiceFilter.class);
                bind(new TypeLiteral<AppServerHandler<RestContact>>() {})
                    .toInstance(appServerHandler);
              }
            });

    final FilterHolder guiceFilter = new FilterHolder(injector.getInstance(GuiceFilter.class));
    servletContextHandler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class));

    server.setHandler(servletContextHandler);
  }
 static {
   for (TransactionStateDeserialization value :
       EnumSet.allOf(TransactionStateDeserialization.class)) {
     nameToValueMap.put(value.name(), value);
     idToValueMap.put(value.getId(), value);
   }
 }
Esempio n. 30
0
  enum Result {
    Unsupported,
    Replied,
    ReplySuccess,
    ReplyFailure;

    public static final Set<Result> VALUES =
        Collections.unmodifiableSet(EnumSet.allOf(Result.class));

    /**
     * @param name The result name - ignored if {@code null}/empty
     * @return The matching {@link Result} value (case <U>insensitive</U>) or {@code null} if no
     *     match found
     */
    public static Result fromName(String name) {
      if (GenericUtils.isEmpty(name)) {
        return null;
      }

      for (Result r : VALUES) {
        if (name.equalsIgnoreCase(r.name())) {
          return r;
        }
      }

      return null;
    }
  }