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.blacklocus.webapp.RunServer.java

@Override
public void go() throws Exception {

    WebAppContext webApp = new WebAppContext();
    // Effectively removes the "no-JSP support" warning, because we don't want dirty, stinkin' JSP support ever.
    webApp.setDefaultsDescriptor("webdefault-nojsp.xml");

    // Fixes serving static resources correctly. Without this, no charset is set in the Content-Type header and
    // 'good' browsers do a terrible job at guessing. Does not affect Java resources, which must specify
    // their own @Produces (usually by extending BaseJsonResource).
    webApp.addFilter(new StaticResourceUTF8CharEncodingFilterHolder(), "/*",
            EnumSet.allOf(DispatcherType.class));

    ////////////////////
    // Prepare jersey

    // as a filter-specifically because that can support falling back to static content when no java resource matches
    FilterHolder jerseyFilter = new FilterHolder(ServletContainer.class);
    jerseyFilter.setName(prcCls.getName());
    jerseyFilter.setInitParameter(ServletContainer.APPLICATION_CONFIG_CLASS, prcCls.getCanonicalName());
    jerseyFilter.setInitParameter(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX,
            $.getString(PROP_STATIC_CONTENT_REGEX));
    jerseyFilter.setInitParameter(ResourceConfig.PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS,
            SingletonFactory.class.getCanonicalName());
    jerseyFilter.setInitParameter(ResourceConfig.FEATURE_DISABLE_WADL, "true");
    jerseyFilter.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
            AccessControlAllowOriginAllContainerResponseFilter.class.getCanonicalName());
    jerseyFilter.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");

    Map<String, String> addtionalInitParams = getAdditionalJerseyInitParameters();
    for (Map.Entry<String, String> initParam : addtionalInitParams.entrySet()) {
        // must iterate because jerseyFilter.setInitParameters replaces everything
        jerseyFilter.setInitParameter(initParam.getKey(), initParam.getValue());
    }//from  w ww .ja v a2 s  . c om

    webApp.addFilter(jerseyFilter, "/*", EnumSet.allOf(DispatcherType.class));

    ////////////////////////////////////////
    // prepare static resources locations

    final Resource staticResources;
    String explicitStaticDirs = propSet.getString(PROP_STATIC_DIRS);
    if (explicitStaticDirs == null) {
        // Single static resource directory in the classpath:static/ folder.
        //noinspection ConstantConditions
        URL staticDir = prcCls.getClassLoader().getResource("static");
        staticResources = staticDir == null ? Resource.newResource("")
                : Resource.newResource(staticDir.toExternalForm());
    } else {
        // Explicitly named static resource directories. There may be multiple. First match wins.
        staticResources = new ResourceCollection(explicitStaticDirs.split(";"));
    }

    webApp.setBaseResource(staticResources);

    ///////////////////////////////////
    // initialize network listeners

    SERVER = new Server(
            new InetSocketAddress(propSet.getString(PROP_JETTY_HOST), propSet.getInt(PROP_JETTY_PORT)));
    SslSelectChannelConnector ssl = createSsl();
    if (ssl != null) {
        SERVER.addConnector(ssl);
    }
    SERVER.setHandler(webApp);
    SERVER.start();
    SERVER.join(); // blocks this thread

}

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

/**
 Sets the PhotoInfo record that will be edited
 @param photo The photoInfo object that is to be edited. If null the a new PhotoInfo record will be created
 *//*from   ww  w  .j a  v  a 2s  .  c  o m*/
public void setPhoto(PhotoInfo photo) {
    if (photo != null) {
        isCreatingNew = false;
    } else {
        isCreatingNew = true;
    }
    this.photos = new PhotoInfo[1];
    photos[0] = (PhotoInfo) getPersistenceContext().merge(photo);
    cmd = new ChangePhotoInfoCommand(photo.getUuid());
    for (PhotoInfoFields f : EnumSet.allOf(PhotoInfoFields.class)) {
        updateViews(null, f);
    }

    folderCtrl.setPhotos(this.photos, false);
    tagCtrl.setPhotos(photos);
    photosChanged();
}

From source file:com.admc.jcreole.CreoleParseTest.java

@org.junit.Test
public void parseTest() throws IOException {
    if (htmlExpectFile != null)
        assertNotNull("Missing expect file: " + htmlExpectFile.getAbsolutePath(), htmlFile);
    Object retVal = null;/*  w  w  w  . j a v  a 2  s.  c o m*/
    try {
        CreoleParser parser = new CreoleParser();
        parser.setPrivileges(EnumSet.allOf(JCreolePrivilege.class));
        /* Replace the statement above with something like this to test
         * privileges:
        parser.setPrivileges(EnumSet.of(
            JCreolePrivilege.ENUMFORMATS,
            JCreolePrivilege.TOC,
            JCreolePrivilege.RAWHTML,
            JCreolePrivilege.STYLESHEET,
            JCreolePrivilege.JCXBLOCK,
            JCreolePrivilege.JCXSPAN,
            JCreolePrivilege.STYLER
        ));
        */
        parser.setInterWikiMapper(new InterWikiMapper() {
            // Use wiki name of "nil" to force lookup failure for path.
            // Use wiki page of "nil" to force lookup failure for label.
            public String toPath(String wikiName, String wikiPage) {
                if (wikiName != null && wikiName.equals("nil"))
                    return null;
                return "{WIKI-LINK to: " + wikiName + '|' + wikiPage + '}';
            }

            public String toLabel(String wikiName, String wikiPage) {
                if (wikiPage == null)
                    throw new RuntimeException("Null page name sent to InterWikiMapper");
                if (wikiPage.equals("nil"))
                    return null;
                return "{LABEL for: " + wikiName + '|' + wikiPage + '}';
            }
        });
        retVal = parser.parse(CreoleScanner.newCreoleScanner(creoleFile, false, null));
    } catch (Exception e) {
        if (!shouldSucceed)
            return; // A ok.  No output file to write.
        AssertionError ae = new AssertionError("Failed to parse '" + creoleFile + "'");
        ae.initCause(e);
        throw ae;
    }
    FileUtils.writeStringToFile(htmlFile, ((retVal == null) ? "" : (((WashedSymbol) retVal).toString())),
            "UTF-8");
    if (!shouldSucceed)
        fail("Should have failed, but generated '" + htmlFile + "'");
    assertTrue("From '" + creoleFile + "':  '" + htmlFile + "' != '" + htmlExpectFile + "'",
            FileUtils.contentEquals(htmlExpectFile, htmlFile));
    htmlFile.delete();
}

From source file:com.blackducksoftware.integration.hub.detect.workflow.file.DirectoryManager.java

public DirectoryManager(final DirectoryOptions directoryOptions, final DetectRun detectRun) {
    if (StringUtils.isBlank(directoryOptions.getSourcePathOverride())) {
        sourceDirectory = new File(System.getProperty("user.dir"));
    } else {//from   w  ww  .j av a 2s .c  om
        sourceDirectory = new File(directoryOptions.getSourcePathOverride());
    }
    logger.info("Source directory: " + sourceDirectory.getAbsolutePath());

    userHome = new File(System.getProperty("user.home"));

    File outputDirectory;
    if (StringUtils.isBlank(directoryOptions.getOutputPathOverride())) {
        outputDirectory = new File(userHome, "blackduck");
        if (outputDirectory.getAbsolutePath().contains("systemprofile")) {
            logger.warn(
                    "You appear to be running in 'systemprofile' which can happen when detect is invoked by a system account or as a service.");
            logger.warn("If detect has full access to the output directory, no further action is necessary.");
            logger.warn(
                    "However, this folder typically has restricted access and may cause exceptions in detect.");
            logger.warn("To ensure continued operation, supply an output directory using "
                    + DetectProperty.DETECT_OUTPUT_PATH.getPropertyName() + " in the future.");
        }
    } else {
        outputDirectory = new File(directoryOptions.getOutputPathOverride());
    }
    logger.info("Output directory: " + outputDirectory.getAbsolutePath());

    EnumSet.allOf(OutputDirectory.class).stream()
            .forEach(it -> outputDirectories.put(it, new File(outputDirectory, it.getDirectoryName())));

    File possibleRunDirectory = new File(getOutputDirectory(OutputDirectory.Runs), detectRun.getRunId());
    if (possibleRunDirectory.exists()) {
        logger.warn(
                "A run directory already exists with this detect run id. Will attempt to use a UUID for the run folder in addition.");
        possibleRunDirectory = new File(getOutputDirectory(OutputDirectory.Runs),
                detectRun.getRunId() + "-" + java.util.UUID.randomUUID());
    }
    runDirectory = possibleRunDirectory;

    logger.info("Run directory: " + runDirectory.getAbsolutePath());

    EnumSet.allOf(RunDirectory.class).stream()
            .forEach(it -> runDirectories.put(it, new File(runDirectory, it.getDirectoryName())));

    //overrides
    if (StringUtils.isNotBlank(directoryOptions.getBdioOutputPathOverride())) {
        runDirectories.put(RunDirectory.Bdio, new File(directoryOptions.getBdioOutputPathOverride()));
    }

    if (StringUtils.isNotBlank(directoryOptions.getScanOutputPathOverride())) {
        runDirectories.put(RunDirectory.Scan, new File(directoryOptions.getScanOutputPathOverride()));
    }

    runDirectories.values().forEach(it -> temporaryFiles.add(it));
}

From source file:org.apache.hadoop.tools.util.TestDistCpUtils.java

public void testUnpackAttributes() {
    EnumSet<FileAttribute> attributes = EnumSet.allOf(FileAttribute.class);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("RCBUGPAXT"));

    attributes.remove(FileAttribute.REPLICATION);
    attributes.remove(FileAttribute.CHECKSUMTYPE);
    attributes.remove(FileAttribute.ACL);
    attributes.remove(FileAttribute.XATTR);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("BUGPT"));

    attributes.remove(FileAttribute.TIMES);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("BUGP"));

    attributes.remove(FileAttribute.BLOCKSIZE);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("UGP"));

    attributes.remove(FileAttribute.GROUP);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("UP"));

    attributes.remove(FileAttribute.USER);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("P"));

    attributes.remove(FileAttribute.PERMISSION);
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes(""));
}

From source file:net.aethersanctum.lilrest.server.JaxRsServerModule.java

@Provides
public ServletContextHandler servletContext(GuiceResteasyBootstrapServletContextListener resteasyListener,
        GuiceFilter guiceFilter, GuiceServletContextListener guiceServletContextListener) {
    final FilterHolder guiceFilterHolder = new FilterHolder(guiceFilter);
    final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.addFilter(guiceFilterHolder, "/*", EnumSet.allOf(DispatcherType.class));
    context.addEventListener(resteasyListener);
    context.addEventListener(guiceServletContextListener);
    return context;
}

From source file:org.glite.authz.pap.authz.PAPPermission.java

@Override
public String toString() {

    if (this.permissions.containsAll(EnumSet.allOf(PermissionFlags.class)))
        return "ALL";

    return StringUtils.join(permissions.iterator(), "|");

}

From source file:org.apigw.authserver.svc.impl.AdministrationServicesImplTest.java

@Test
public void testRegisterApplication() {
    administrationServices.registerApplication("app-two", "Two-2-Tango",
            "The second application in the test suite.", 0L, 0L, "IssuerDN", "SubjectDN", "Two Testing",
            Arrays.asList(new String[] { READ_SCOPE }), "twotwo", EnumSet.allOf(CertifiedClientRole.class),
            "http://localhost:8080/two");
    CertifiedClient appTwo = certifiedClientRepository.findByClientId("app-two");
    Assert.assertNotNull(appTwo);/* w  w  w  .  j  av a  2s  .co m*/
    assertEquals("Two-2-Tango", appTwo.getName());
    assertEquals(new Integer(0), appTwo.getAccessTokenValiditySeconds());
    assertEquals(new Integer(0), appTwo.getRefreshTokenValiditySeconds());
    assertEquals("app-two", appTwo.getClientId());
    assertEquals("twotwo", appTwo.getClientSecret());
    assertEquals("http://localhost:8080/two", appTwo.getClientUrl());
    assertEquals("The second application in the test suite.", appTwo.getDescription());
    assertEquals("Two Testing", appTwo.getOrganization());
    assertEquals("IssuerDN", appTwo.getX509CertificateIssuerDN());
    assertEquals("SubjectDN", appTwo.getX509CertificateSubjectDN());
}

From source file:com.vmware.upgrade.progress.DefaultExecutionStateAggregatorTest.java

private Map<ExecutionState, Set<ExecutionState>> computeAllStateTransitions() {
    Map<ExecutionState, Set<ExecutionState>> stateTransitions = new HashMap<ExecutionState, Set<ExecutionState>>();

    for (ExecutionState state : EnumSet.allOf(ExecutionState.class)) {
        stateTransitions.put(state, computeStateTransitions(state));
    }/*from w w w  .  j  a  v a2  s.co  m*/

    return stateTransitions;
}

From source file:com.tcloud.bee.key.server.jetty.config.WebAppInitializer.java

/**
 * Register JerseyServlet Config//  w  ww  .  j  a  v a2  s .  c o  m
 * 
 * @param servletContext
 */
private void configurationJersey(ServletContext servletContext) {

    FilterRegistration.Dynamic filterDinamic = servletContext.addFilter("jersey",
            new org.glassfish.jersey.servlet.ServletContainer());
    filterDinamic.setInitParameter("javax.ws.rs.Application",
            "org.apache.hadoop.io.crypto.bee.key.server.jetty.config.JerseyApplicationConfig");
    filterDinamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/api/*");
}