Example usage for java.util EnumSet allOf

List of usage examples for java.util EnumSet allOf

Introduction

In this page you can find the example usage for java.util EnumSet allOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType) 

Source Link

Document

Creates an enum set containing all of the elements in the specified element type.

Usage

From source file:com.ethercis.vehr.Launcher.java

public void start(String[] args) throws Exception {
    boolean debug = false;
    List<String> normalizedArguments = new ArrayList<>(Arrays.asList(args));

    CommandLineParser parser = new DefaultParser();
    CommandLine commandLine = parser.parse(options, args);

    if (commandLine.hasOption("debug"))
        debug = true;/*  w w  w  .j a  v  a2s . co m*/

    if (commandLine.hasOption("dialect")) {
        String compatibilityValue = commandLine.getOptionValue("dialect", "STANDARD");
        //TODO: add compatibility argument in args
        normalizedArguments.add("-" + I_ServiceRunMode.SERVER_DIALECT_PARAMETER);
        normalizedArguments.add(I_ServiceRunMode.DialectSpace.valueOf(compatibilityValue).name());
    }

    Integer httpPort = Integer.parseInt(commandLine.getOptionValue(command_server_port, default_port));
    String httpHost = commandLine.getOptionValue(command_server_host, default_host);

    InetSocketAddress socketAddress = new InetSocketAddress(httpHost, httpPort);

    logger.info("Server starting on host:" + httpHost + " port:" + httpPort);

    server = new Server(socketAddress);
    if (debug)
        server.setStopAtShutdown(true);
    //create and initialize vEhrHandler
    vEhrGateServlet = new VEhrGateServlet();
    vEhrGateServlet.init(normalizedArguments.toArray(new String[] {}));

    ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/",
            ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY);

    //add filter to allow CORS
    FilterHolder cors = new FilterHolder(CrossOriginFilter.class);
    //        FilterHolder cors = servletContextHandler.addFilter(CrossOriginFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    cors.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, null);
    cors.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
    cors.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, "*");
    cors.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET, POST, DELETE, PUT, OPTIONS, HEAD");
    cors.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM,
            "X-Requested-With,Content-Type,Accept,Origin");
    cors.setName("cross-origin");
    FilterMapping filterMapping = new FilterMapping();
    filterMapping.setFilterName("cross-origin");
    filterMapping.setPathSpec("*");
    servletContextHandler.addFilter(cors, "/*", EnumSet.allOf(DispatcherType.class));
    //        servletContextHandler.addFilter(cors, "/*", null);
    //        servletContextHandler.getServletHandler().addFilter(cors, filterMapping);

    ServletHolder servletHolder = new ServletHolder(vEhrGateServlet);
    servletContextHandler.addServlet(servletHolder, "/");

    HandlerList handlerList = new HandlerList();
    handlerList.setHandlers(new Handler[] { servletContextHandler, new DefaultHandler() });
    server.setHandler(handlerList);

    try {
        server.start();
    } catch (BindException e) {
        logger.error("Address already in use! (" + socketAddress.toString() + ")");
        throw new IllegalArgumentException("Address already in use! (" + socketAddress.toString() + ")");
    }
    logger.info("Server listening at:" + server.getURI().toString());
    if (!debug)
        server.join();

}

From source file:org.apache.sentry.policy.indexer.TestIndexerAuthorizationProviderGeneralCases.java

@Test
public void testAdmin() throws Exception {
    Set<IndexerModelAction> allActions = EnumSet.allOf(IndexerModelAction.class);
    doTestAuthProviderOnIndexer(SUB_ADMIN, IND_PURCHASES, allActions);
    doTestAuthProviderOnIndexer(SUB_ADMIN, IND_ANALYST1, allActions);
    doTestAuthProviderOnIndexer(SUB_ADMIN, IND_JRANALYST1, allActions);
    doTestAuthProviderOnIndexer(SUB_ADMIN, IND_TMP, allActions);
    doTestAuthProviderOnIndexer(SUB_ADMIN, IND_PURCHASES_PARTIAL, allActions);
}

From source file:io.springagora.store.AppInitializer.java

private void initializeOpenEMInViewFilter(ServletContext container) {
    OpenEntityManagerInViewFilter sessionFilter = new OpenEntityManagerInViewFilter();
    FilterRegistration.Dynamic filterReg = container.addFilter("Open EM In View Filter", sessionFilter);
    filterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, URL_PATTERN_WEB);
    filterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, URL_PATTERN_REST);
}

From source file:io.soabase.core.SoaBundle.java

@Override
public void run(final T configuration, final Environment environment) throws Exception {
    final SoaConfiguration soaConfiguration = ComposedConfigurationAccessor.access(configuration, environment,
            SoaConfiguration.class);

    environment.servlets().addFilter("SoaClientFilter", SoaClientFilter.class)
            .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");

    updateInstanceName(soaConfiguration);
    List<String> scopes = Lists.newArrayList();
    scopes.add(soaConfiguration.getInstanceName());
    scopes.add(soaConfiguration.getServiceName());
    scopes.addAll(soaConfiguration.getScopes());

    Ports ports = getPorts(configuration);
    final SoaInfo soaInfo = new SoaInfo(scopes, ports.mainPort, ports.adminPort,
            soaConfiguration.getServiceName(), soaConfiguration.getInstanceName(),
            soaConfiguration.isRegisterInDiscovery());

    SoaDiscovery discovery = wrapDiscovery(
            checkManaged(environment, soaConfiguration.getDiscoveryFactory().build(environment, soaInfo)));
    SoaDynamicAttributes attributes = wrapAttributes(
            checkManaged(environment, soaConfiguration.getAttributesFactory().build(environment, scopes)));
    LoggingReader loggingReader = initLogging(configuration);

    final SoaFeaturesImpl features = new SoaFeaturesImpl(discovery, attributes, soaInfo,
            new ExecutorBuilder(environment.lifecycle()), loggingReader);
    AbstractBinder binder = new AbstractBinder() {
        @Override//from   ww  w.  jav  a2  s  . c  o m
        protected void configure() {
            bind(features).to(SoaFeatures.class);
            bind(environment.healthChecks()).to(HealthCheckRegistry.class);
            bind(environment.getObjectMapper()).to(ObjectMapper.class);
            bind(environment.metrics()).to(MetricRegistry.class);
        }
    };
    setFeaturesInContext(environment, features);

    checkCorsFilter(soaConfiguration, environment.servlets());
    initJerseyAdmin(soaConfiguration, features, ports, environment, binder);

    startDiscoveryHealth(discovery, soaConfiguration, environment);

    environment.jersey().register(binder);

    addMetrics(environment);
}

From source file:com.hortonworks.streamline.webservice.StreamlineApplication.java

@SuppressWarnings("unchecked")
private void addServletFilters(StreamlineConfiguration configuration, Environment environment) {
    List<ServletFilterConfiguration> servletFilterConfigurations = configuration.getServletFilters();
    if (servletFilterConfigurations != null && !servletFilterConfigurations.isEmpty()) {
        for (ServletFilterConfiguration servletFilterConfiguration : servletFilterConfigurations) {
            try {
                FilterRegistration.Dynamic dynamic = environment.servlets().addFilter(
                        servletFilterConfiguration.getClassName(),
                        (Class<? extends Filter>) Class.forName(servletFilterConfiguration.getClassName()));
                dynamic.setInitParameters(servletFilterConfiguration.getParams());
                dynamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
                LOG.info("Added servlet filter with configuration {}", servletFilterConfiguration);
            } catch (Exception e) {
                LOG.error("Error occurred while adding servlet filter {}", servletFilterConfiguration);
                throw new RuntimeException(e);
            }//from   ww  w.j a v  a  2  s .co  m
        }
    } else {
        LOG.info("No servlet filters configured");
    }
}

From source file:org.apache.sentry.policy.search.TestSearchAuthorizationProviderGeneralCases.java

@Test
public void testAdmin() throws Exception {
    Set<SearchModelAction> allActions = EnumSet.allOf(SearchModelAction.class);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_PURCHASES, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_ANALYST1, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_JRANALYST1, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_TMP, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_PURCHASES_PARTIAL, allActions);
}

From source file:com.hortonworks.streamline.streams.service.FileCatalogResource.java

/**
 * Adds given resource to the configured file-storage and adds an entry in entity storage.
 *
 * Below example describes how a file can be added along with metadata
 * <blockquote><pre>//from  w w  w  .  j a v a  2 s .  c o  m
 * curl -X POST -i -F file=@user-lib.jar -F "fileInfo={\"name\":\"jar-1\",\"version\":1};type=application/json"  http://localhost:8080/api/v1/catalog/files
 *
 * HTTP/1.1 100 Continue
 *
 * HTTP/1.1 201 Created
 * Date: Fri, 15 Apr 2016 10:36:33 GMT
 * Content-Type: application/json
 * Content-Length: 239
 *
 * {"responseCode":1000,"responseMessage":"Success","entity":{"id":1234,"name":"jar-1","className":null,"storedFileName":"/tmp/test-hdfs/jar-1-ea41fe3a-12f9-45d4-ae24-818d570b8963.jar","version":1,"timestamp":1460716593157,"auxiliaryInfo":null}}
 * </pre></blockquote>
 *
 * @param inputStream actual file content as {@link InputStream}.
 * @param contentDispositionHeader {@link FormDataContentDisposition} instance of the received file
 * @param file configuration of the file resource {@link File}
 * @return
 */
@Timed
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/files")
public Response addFile(@FormDataParam("file") final InputStream inputStream,
        @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader,
        @FormDataParam("fileInfo") final File file, @Context SecurityContext securityContext)
        throws IOException {
    SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_ADMIN);
    log.info("Received fileInfo: [{}]", file);
    File updatedFile = addFile(inputStream, file);
    SecurityUtil.addAcl(authorizer, securityContext, File.NAMESPACE, updatedFile.getId(),
            EnumSet.allOf(Permission.class));
    return WSUtils.respondEntity(updatedFile, CREATED);
}

From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java

/**
 * If no value present, choose a empty string
 *
 * @param title//from  w w  w . j a v  a  2 s. c  o m
 * @param link
 * @param description
 * @param language
 * @param imageUrl
 * @return
 */
private Component getSecondStage(Source s) {
    Label header = new Label(Language.get(Word.SOURCE));
    header.addStyleName(ValoTheme.LABEL_H1);

    FormLayout forms = new FormLayout();
    forms.setSizeFull();

    TextField textFieldId = new TextField(Language.get(Word.ID));
    textFieldId.setEnabled(false);
    textFieldId.setValue(s.getId());
    textFieldId.setWidth("750px");

    TextField textFieldName = new TextField(Language.get(Word.NAME));
    textFieldName.setValue(s.getName());
    textFieldName.setWidth("750px");

    TextField textFieldDescription = new TextField(Language.get(Word.DESCRIPTION));
    textFieldDescription.setValue(s.getDescription());
    textFieldDescription.setWidth("750px");

    TextField textFieldURL = new TextField(Language.get(Word.URL));
    if (s.getUrl() != null) {
        textFieldURL.setValue(s.getUrl().toExternalForm());
    }
    textFieldURL.setWidth("750px");

    ComboBox<Category> comboBoxCategories = new ComboBox<>(Language.get(Word.CATEGORY),
            EnumSet.allOf(Category.class));
    comboBoxCategories.setItemCaptionGenerator(c -> c.getName());
    comboBoxCategories.setItemIconGenerator(c -> c.getIcon());
    comboBoxCategories.setEmptySelectionAllowed(false);
    comboBoxCategories.setTextInputAllowed(false);
    comboBoxCategories.setWidth("375px");
    if (s.getCategory() != null) {
        comboBoxCategories.setSelectedItem(s.getCategory());
    }

    ComboBox<Locale> comboBoxLanguage = new ComboBox<>(Language.get(Word.LANGUAGE), getLanguages());
    comboBoxLanguage.setItemCaptionGenerator(l -> l.getDisplayLanguage(VaadinSession.getCurrent().getLocale()));
    comboBoxLanguage.setEmptySelectionAllowed(false);
    comboBoxLanguage.setWidth("375px");
    if (!s.getLanguage().isEmpty()) {
        Locale selected = new Locale(s.getLanguage());
        comboBoxLanguage.setSelectedItem(selected);
    }

    Locale loc = VaadinSession.getCurrent().getLocale();

    Map<String, Locale> countries = getCountries();
    List<Locale> locales = countries.values().parallelStream()
            .sorted((l1, l2) -> l1.getDisplayCountry(loc).compareTo(l2.getDisplayCountry(loc)))
            .collect(Collectors.toList());
    ComboBox<Locale> comboBoxCountry = new ComboBox<>(Language.get(Word.COUNTRY), locales);
    comboBoxCountry.setItemCaptionGenerator(l -> l.getDisplayCountry(VaadinSession.getCurrent().getLocale()));
    comboBoxCountry.setItemIconGenerator(l -> FamFamFlags.fromLocale(l));
    comboBoxCountry.setEmptySelectionAllowed(false);
    comboBoxCountry.setWidth("375px");
    if (!s.getCountry().isEmpty()) {
        comboBoxCountry.setSelectedItem(countries.getOrDefault(s.getCountry(), Locale.ROOT));
    }

    Image imageLogo = new Image(Language.get(Word.LOGO));

    TextField textFieldLogo = new TextField(Language.get(Word.LOGO_URL));
    if (s.getLogo() != null) {
        textFieldLogo.setValue(s.getLogo().toExternalForm());
        imageLogo.setSource(new ExternalResource(s.getLogo()));
    }
    textFieldLogo.addValueChangeListener(ce -> imageLogo.setSource(new ExternalResource(ce.getValue())));
    textFieldLogo.setWidth("750px");

    if (imageLogo.getHeight() > 125) {
        imageLogo.setHeight("125px");
    }

    forms.addComponents(textFieldId, textFieldName, textFieldDescription, textFieldURL, comboBoxCategories,
            comboBoxLanguage, comboBoxCountry, textFieldLogo, imageLogo);

    Runnable cancel = () -> close();
    Runnable next = () -> validateSecondStage(s, textFieldId.getValue(), textFieldName.getValue(),
            textFieldURL.getValue(), textFieldDescription.getValue(),
            comboBoxCategories.getSelectedItem().orElse(null),
            comboBoxLanguage.getSelectedItem().orElse(Locale.ROOT),
            comboBoxCountry.getSelectedItem().orElse(Locale.ROOT), textFieldLogo.getValue());

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.addComponents(header, forms, getFooter(cancel, next));
    windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    return windowLayout;
}

From source file:org.photovault.swingui.selection.PhotoSelectionController.java

/**
 Sets a group of PhotoInfo records that will be edited. If all of the 
 records will have same value for a certain field the views will display 
 this value. Otherwise, <code>null</code> is displayed and if the value 
 is changed in a view, the new value is updated to all controlled objects.
 *///ww  w.java 2s .  c o  m
public void setPhotos(PhotoInfo[] photos) {
    // Ensure that the photo instances belong to our persistence context
    if (photos != null) {
        this.photos = new PhotoInfo[photos.length];
        for (int n = 0; n < photos.length; n++) {
            this.photos[n] = (PhotoInfo) getPersistenceContext().merge(photos[n]);
        }
    } else {
        this.photos = null;
    }
    // If we are editing several photos simultaneously we certainly are not creating a new photo...
    isCreatingNew = false;
    List<UUID> photoIds = new ArrayList<UUID>();
    if (photos != null) {
        for (PhotoInfo p : photos) {
            photoIds.add(p.getUuid());
        }
    }
    this.cmd = new ChangePhotoInfoCommand(photoIds);
    for (PhotoInfoFields f : EnumSet.allOf(PhotoInfoFields.class)) {
        updateViews(null, f);
    }
    folderCtrl.setPhotos(this.photos, false);
    tagCtrl.setPhotos(this.photos);
    for (FieldController c : fieldControllers.values()) {
        c.setPhotos(photos);
    }
    photosChanged();
}

From source file:org.apache.sentry.policy.solr.TestSolrAuthorizationProviderGeneralCases.java

@Test
public void testAdmin() throws Exception {
    Set<SolrModelAction> allActions = EnumSet.allOf(SolrModelAction.class);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_PURCHASES, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_ANALYST1, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_JRANALYST1, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_TMP, allActions);
    doTestAuthProviderOnCollection(SUB_ADMIN, COLL_PURCHASES_PARTIAL, allActions);
}