Example usage for java.util EnumSet of

List of usage examples for java.util EnumSet of

Introduction

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

Prototype

public static <E extends Enum<E>> EnumSet<E> of(E e1, E e2, E e3) 

Source Link

Document

Creates an enum set initially containing the specified elements.

Usage

From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java

public DocumentUpdateView(Document document) {
    initComponents();/*  ww  w  .j  a  v  a 2  s. c om*/
    addUnitButton.setIcon(new ImageIcon(loadPlus()));
    addProductBatchButton.setIcon(new ImageIcon(loadAddProductBatch()));
    moveUpButton.setIcon(new ImageIcon(loadUp()));
    moveDownButton.setIcon(new ImageIcon(loadDown()));
    removePositionButton.setIcon(new ImageIcon(loadMinus()));
    convertToWarrantyPositionButton.setIcon(new ImageIcon(loadAddCoin()));

    initFxComponents();
    this.document = document;
    positions.addAll(document.getPositions().values());
    this.accessCos = Lookup.getDefault().lookup(Guardian.class);
    refreshAddressArea();

    if (!Client.hasFound(WarrantyHook.class))
        convertToWarrantyPositionButton.setVisible(false);

    if (document.isClosed()
            || EnumSet.of(DocumentType.COMPLAINT, DocumentType.CREDIT_MEMO, DocumentType.ANNULATION_INVOICE)
                    .contains(document.getType())) {
        disableComponents(addProductBatchButton, addUnitButton, unitInputField, addServiceButton,
                shippingCostButton);
    } else if (document.getType() == DocumentType.INVOICE) {
        accessCos.add(addProductBatchButton, UPDATE_PRICE_INVOICES);
        accessCos.add(addUnitButton, UPDATE_PRICE_INVOICES);
        accessCos.add(unitInputField, UPDATE_PRICE_INVOICES);
        accessCos.add(addServiceButton, UPDATE_PRICE_INVOICES);
        accessCos.add(shippingCostButton, UPDATE_PRICE_INVOICES);
        accessCos.add(moveDownButton, UPDATE_PRICE_INVOICES);
        accessCos.add(moveUpButton, UPDATE_PRICE_INVOICES);
    } else if (document.getType() == DocumentType.RETURNS || document.getType() == DocumentType.CAPITAL_ASSET)
        disableComponents(addProductBatchButton, addServiceButton, shippingCostButton);
}

From source file:org.obiba.mica.config.WebConfiguration.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    log.info("Web application configuration, using profiles: {}", Arrays.toString(env.getActiveProfiles()));

    initAllowedMethods(servletContext);/*www .  j a  va  2  s  .  com*/
    // Note: authentication filter was already added by Spring

    EnumSet<DispatcherType> disps = EnumSet.of(REQUEST, FORWARD, ASYNC);
    initMetrics(servletContext, disps);

    if (env.acceptsProfiles(Profiles.PROD)) {
        initStaticResourcesProductionFilter(servletContext, disps);
        initCachingHttpHeadersFilter(servletContext, disps);
    }

    initGzipFilter(servletContext, disps);

    log.info("Web application fully configured");
}

From source file:ch.cyberduck.ui.cocoa.controller.BookmarkController.java

public void setProtocolPopup(final NSPopUpButton button) {
    this.protocolPopup = button;
    this.protocolPopup.setEnabled(true);
    this.protocolPopup.setTarget(this.id());
    this.protocolPopup.setAction(Foundation.selector("protocolSelectionChanged:"));
    this.protocolPopup.removeAllItems();
    for (Protocol protocol : protocols.find(new DefaultProtocolPredicate(
            EnumSet.of(Protocol.Type.ftp, Protocol.Type.sftp, Protocol.Type.dav)))) {
        this.addProtocol(protocol);
    }//w ww  . ja  va 2s  .com
    this.protocolPopup.menu().addItem(NSMenuItem.separatorItem());
    for (Protocol protocol : protocols.find(
            new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure,
                    Protocol.Type.b2, Protocol.Type.dracoon, Protocol.Type.googlestorage)))) {
        this.addProtocol(protocol);
    }
    this.protocolPopup.menu().addItem(NSMenuItem.separatorItem());
    for (Protocol protocol : protocols.find(new DefaultProtocolPredicate(
            EnumSet.of(Protocol.Type.dropbox, Protocol.Type.onedrive, Protocol.Type.googledrive)))) {
        this.addProtocol(protocol);
    }
    this.protocolPopup.menu().addItem(NSMenuItem.separatorItem());
    for (Protocol protocol : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.file)))) {
        this.addProtocol(protocol);
    }
    this.protocolPopup.menu().addItem(NSMenuItem.separatorItem());
    for (Protocol protocol : protocols.find(new ProfileProtocolPredicate())) {
        this.addProtocol(protocol);
    }
    this.addObserver(new BookmarkObserver() {
        @Override
        public void change(final Host bookmark) {
            protocolPopup.selectItemAtIndex(protocolPopup
                    .indexOfItemWithRepresentedObject(String.valueOf(bookmark.getProtocol().hashCode())));
        }
    });
}

From source file:com.seajas.search.contender.jms.endpoint.ProcessorEndpoint.java

/**
 * Process the incoming secondary message and delegate it to the SourceElement or reindexing processor.
 *
 * @param message/*ww  w .java 2  s  .  c o  m*/
 */
@ServiceActivator(inputChannel = "secondaryProcessingChannel")
public void processSecondary(final Message<ObjectId> message) {
    CompositeEntry entry = storageService.retrieveEntryById(message.getPayload());

    try {
        if (entry == null)
            throw new IllegalArgumentException("The given composite entry does not exist");

        ManagementState.getTypedEntries(entry).incrementCurrentMinute();

        if (Boolean.TRUE.equals(message.getHeaders().get(MessageConstants.HEADER_CHANNEL_REINDEXING))) {
            // The processToModified call should reset the entry-state back to 'Content'

            if (EnumSet.of(CompositeState.Content, CompositeState.InitialDocument,
                    CompositeState.CompletedDocument).contains(entry.getCurrentState())) {
                if (entry.getFailureState() != null)
                    logger.warn(String.format(
                            "Trying to reindex element with ID %s - which has failed before at state %s",
                            entry.getId().toString(), entry.getFailureState().name()));

                if (entry.getOriginalContent() != null) {
                    if (logger.isInfoEnabled())
                        logger.info(String.format(
                                "Reindexing element with ID '%s', state '%s', and failure state %s",
                                entry.getId(), entry.getCurrentState(),
                                entry.getFailureState() != null ? "'" + entry.getFailureState() + "'"
                                        : "(none)"));

                    sourceElementProcessor.processToModified(entry,
                            entry.getOriginalContent().getDateSubmitted());

                    storageService.saveEntry(entry);

                    injectionService.injectContent(entry.getId());
                } else {
                    // Can be explained if the failure state has been set

                    if (entry.getFailureState() == null)
                        throw new IllegalStateException(
                                "The document destined for re-indexing should contain an original content descriptor - but doesn't");
                }
            } else
                throw new IllegalArgumentException(
                        "The document destined for re-indexing is not of type \"Content\", \"InitialDocument\" or \"CompletedDocument\"");
        } else {
            String cacheKey = cacheService.createCompositeKey(entry.getElement().getUri().toString(),
                    entry.getSource().getResultParameters());

            // Check this element against the cache (processing and regular)

            if (!cacheService.isCached(cacheKey)) {
                // Place it into the processing cache (and remove it again through finalizeMessageProcessing())

                processingCache.put(new Element(cacheKey, null));

                try {
                    // This is where we handle Feeds, Archives, and SourceElements

                    if (sourceElementProcessor.processToOriginal(entry)) {
                        // And add the modified content, which we separate like this for the purpose of allowing re-indexing to skip this step

                        if (entry.getOriginalContent() != null && entry.getFailureState() == null) {
                            sourceElementProcessor.processToModified(entry,
                                    entry.getOriginalContent().getDateSubmitted());

                            storageService.saveEntry(entry);

                            if (entry.getOriginalContent().getId() == null)
                                logger.error(
                                        "Not injecting entry for enriching purposes - content apparently incorrectly stored - no ID was set on it");
                            else
                                injectionService.injectContent(entry.getId());
                        } else {
                            storageService.saveEntry(entry);

                            if (entry.getFailureState() != null)
                                logger.error(
                                        "Not injecting entry for enriching purposes - failure state has been set to "
                                                + entry.getFailureState());
                            else if (entry.getOriginalContent() == null)
                                logger.error(
                                        "Not injecting entry for enriching purposes - original content has not been set or retrieved (without a failure state or error - weird)");
                        }
                    } else {
                        logger.error("Not injecting entry for enriching purposes - original processing failed");

                        storageService.saveEntry(entry);
                    }
                } finally {
                    finalizeMessageProcessing(cacheKey);
                }
            } else
                logger.warn("[" + cacheKey
                        + "] The entry (by its composite key) being referred to has already been cached - this should (almost) never happen as the cache is already checked prior to injection.");
        }
    } catch (RuntimeException e) {
        logger.error("Uncaught runtime exception", e);

        if (entry.getFailureState() == null) {
            entry.setFailureState(CompositeState.Content);

            storageService.saveEntry(entry);
        }

        throw e;
    } finally {
        if (entry != null)
            storageService.closeEntry(entry);
    }
}

From source file:at.ac.tuwien.infosys.util.ImageUtil.java

private void saveFile(URL url, Path file) throws IOException {
    ReadableByteChannel rbc = Channels.newChannel(url.openStream());
    FileChannel channel = FileChannel.open(file, EnumSet.of(StandardOpenOption.CREATE,
            StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE));
    channel.transferFrom(rbc, 0, Long.MAX_VALUE);
    channel.close();/*  w  w  w  .  j  ava  2s .c o m*/
}

From source file:com.netflix.genie.web.services.impl.DiskJobFileServiceImpl.java

/**
 * {@inheritDoc}/*from   ww w .j  ava 2  s.c  o m*/
 */
@Override
// TODO: We should be careful about how large the byte[] is. Perhaps we should have precondition to protect memory
//       or we should wrap calls to this in something that chunks it off an input stream or just take this in as
//       input stream
public void updateFile(final String jobId, final String relativePath, final long startByte, final byte[] data)
        throws IOException {
    log.debug("Attempting to write {} bytes from position {} into log file {} for job {}", data.length,
            startByte, relativePath, jobId);
    final Path jobFile = this.jobsDirRoot.resolve(jobId).resolve(relativePath);

    if (Files.notExists(jobFile)) {
        // Make sure all the directories exist on disk
        final Path logFileParent = jobFile.getParent();
        if (logFileParent != null) {
            this.createOrCheckDirectory(logFileParent);
        }
    } else if (Files.isDirectory(jobFile)) {
        // TODO: Perhaps this should be different exception
        throw new IllegalArgumentException(relativePath + " is a directory not a file. Unable to update");
    }

    try (FileChannel fileChannel = FileChannel.open(jobFile,
            EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.SPARSE))) {
        // Move the byteChannel to the start byte
        fileChannel.position(startByte);

        // The size and length are ignored in this implementation as we just assume we're writing everything atm
        // TODO: Would it be better to provide an input stream and buffer the output?
        final ByteBuffer byteBuffer = ByteBuffer.wrap(data);

        while (byteBuffer.hasRemaining()) {
            fileChannel.write(byteBuffer);
        }
    }
}

From source file:ch.cyberduck.core.sds.triplecrypt.CryptoWriteFeatureTest.java

@Test
public void testWriteMultipart() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new Path("CD-TEST-ENCRYPTED",
            EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.vault));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);/*from w ww.j  a v  a  2s.c  om*/
    final Path test = new Path(room, UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file, Path.Type.decrypted));
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(test, status), new DisabledConnectionCallback());
    final CryptoWriteFeature writer = new CryptoWriteFeature(session, new SDSMultipartWriteFeature(session));
    final StatusOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    final VersionId version = out.getStatus();
    assertNotNull(version);
    assertTrue(new DefaultFindFeature(session).find(test));
    assertEquals(content.length, new SDSAttributesFinderFeature(session).find(test).getSize());
    final byte[] compare = new byte[content.length];
    final InputStream stream = new CryptoReadFeature(session, new SDSReadFeature(session)).read(test,
            new TransferStatus(), new ConnectionCallback() {
                @Override
                public void warn(final Host bookmark, final String title, final String message,
                        final String defaultButton, final String cancelButton, final String preference)
                        throws ConnectionCanceledException {
                    //
                }

                @Override
                public Credentials prompt(final Host bookmark, final String title, final String reason,
                        final LoginOptions options) throws LoginCanceledException {
                    return new VaultCredentials("ahbic3Ae");
                }
            });
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new SDSDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:com.streamsets.pipeline.lib.remote.ChrootSFTPClient.java

public OutputStream openForWriting(String path) throws IOException {
    String toPath = prependRoot(path);
    // Create the toPath's parent dir(s) if they don't exist
    String toDir = Paths.get(toPath).getParent().toString();
    sftpClient.mkdirs(toDir);/*from   w  ww  .j a va  2 s  .com*/
    RemoteFile remoteFile = sftpClient.open(toPath, EnumSet.of(OpenMode.WRITE, OpenMode.CREAT, OpenMode.TRUNC),
            FileAttributes.EMPTY);
    return SFTPStreamFactory.createOutputStream(remoteFile);
}