Example usage for org.apache.commons.lang3 StringUtils trim

List of usage examples for org.apache.commons.lang3 StringUtils trim

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils trim.

Prototype

public static String trim(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null .

The String is trimmed using String#trim() .

Usage

From source file:net.lmxm.ute.configuration.ConfigurationReader.java

/**
 * Parses the Maven repository location.
 *
 * @param locationType the location type
 * @return the Maven repository location
 *///from  w ww  .java 2 s.  c  o m
private MavenRepositoryLocation parseMavenRepositoryLocation(final MavenRepositoryLocationType locationType) {
    final String prefix = "parseMavenRepositoryLocation() :";

    LOGGER.debug("{} entered", prefix);

    final MavenRepositoryLocation location = new MavenRepositoryLocation();

    location.setId(StringUtils.trim(locationType.getId()));
    location.setUrl(StringUtils.trim(locationType.getUrl()));

    LOGGER.debug("{} returning {}", prefix, location);

    return location;
}

From source file:com.thinkbiganalytics.feedmgr.sla.DefaultServiceLevelAgreementService.java

/**
 * In order to Save an SLA if it is related to a Feed(s) the user needs to have EDIT_DETAILS permission on the Feed(s)
 *
 * @param serviceLevelAgreement the sla to save
 * @param feed                  an option Feed to relate to this SLA.  If this is not present the related feeds are also embedded in the SLA policies.  The Feed is a pointer access to the current
 *                              feed the user is editing if they are creating an SLA from the Feed Details page. If creating an SLA from the main SLA page the feed property will not be populated.
 *//*  w  ww .  j  a  va 2s .  c  om*/
private ServiceLevelAgreement saveAndScheduleSla(ServiceLevelAgreementGroup serviceLevelAgreement,
        FeedMetadata feed) {

    //ensure user has permissions to edit the SLA
    if (serviceLevelAgreement != null) {

        ServiceLevelAgreementMetricTransformerHelper transformer = new ServiceLevelAgreementMetricTransformerHelper();

        //Read the feeds on the SLA as a Service. Then verify the current user has access to edit these feeds
        List<String> feedsOnSla = metadataAccess.read(() -> {
            List<String> feedIds = new ArrayList<>();
            //all referencing Feeds
            List<String> systemCategoryAndFeedNames = transformer.getCategoryFeedNames(serviceLevelAgreement);

            for (String categoryAndFeed : systemCategoryAndFeedNames) {
                //fetch and update the reference to the sla
                String categoryName = StringUtils.trim(StringUtils.substringBefore(categoryAndFeed, "."));
                String feedName = StringUtils.trim(StringUtils.substringAfterLast(categoryAndFeed, "."));
                Feed feedEntity = feedProvider.findBySystemName(categoryName, feedName);
                if (feedEntity != null) {
                    feedIds.add(feedEntity.getId().toString());
                }
            }
            return feedIds;
        }, MetadataAccess.SERVICE);

        boolean allowedToEdit = feedsOnSla.isEmpty() ? true
                : feedsOnSla.stream().allMatch(feedId -> feedManagerFeedService.checkFeedPermission(feedId,
                        FeedAccessControl.EDIT_DETAILS));

        if (allowedToEdit) {

            return metadataAccess.commit(() -> {

                //Re read back in the Feeds for this session
                Set<Feed> slaFeeds = new HashSet<Feed>();
                Set<Feed.ID> slaFeedIds = new HashSet<Feed.ID>();
                feedsOnSla.stream().forEach(feedId -> {
                    Feed feedEntity = feedProvider.findById(feedProvider.resolveId(feedId));
                    if (feedEntity != null) {
                        slaFeeds.add(feedEntity);
                        slaFeedIds.add(feedEntity.getId());
                    }
                });

                if (feed != null) {
                    feedManagerFeedService.checkFeedPermission(feed.getId(), FeedAccessControl.EDIT_DETAILS);
                }

                if (feed != null) {
                    transformer.applyFeedNameToCurrentFeedProperties(serviceLevelAgreement,
                            feed.getCategory().getSystemName(), feed.getSystemFeedName());
                }
                ServiceLevelAgreement sla = transformer.getServiceLevelAgreement(serviceLevelAgreement);

                ServiceLevelAgreementBuilder slaBuilder = null;
                com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID existingId = null;
                if (StringUtils.isNotBlank(sla.getId())) {
                    existingId = slaProvider.resolve(sla.getId());
                }
                if (existingId != null) {
                    slaBuilder = slaProvider.builder(existingId);
                } else {
                    slaBuilder = slaProvider.builder();
                }

                slaBuilder.name(sla.getName()).description(sla.getDescription());
                for (com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group : sla.getGroups()) {
                    ObligationGroupBuilder groupBuilder = slaBuilder
                            .obligationGroupBuilder(ObligationGroup.Condition.valueOf(group.getCondition()));
                    for (Obligation o : group.getObligations()) {
                        groupBuilder.obligationBuilder().metric(o.getMetrics()).description(o.getDescription())
                                .build();
                    }
                    groupBuilder.build();
                }
                com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement savedSla = slaBuilder.build();

                List<ServiceLevelAgreementActionConfiguration> actions = transformer
                        .getActionConfigurations(serviceLevelAgreement);

                // now assign the sla checks
                slaProvider.slaCheckBuilder(savedSla.getId()).removeSlaChecks().actionConfigurations(actions)
                        .build();

                if (feed != null) {
                    Feed.ID feedId = feedProvider.resolveFeed(feed.getFeedId());
                    if (!slaFeedIds.contains(feedId)) {
                        Feed feedEntity = feedProvider.getFeed(feedId);
                        slaFeeds.add(feedEntity);
                    }
                }
                //relate them
                Set<Feed.ID> feedIds = new HashSet<>();
                FeedServiceLevelAgreementRelationship feedServiceLevelAgreementRelationship = feedSlaProvider
                        .relateFeeds(savedSla, slaFeeds);
                if (feedServiceLevelAgreementRelationship != null
                        && feedServiceLevelAgreementRelationship.getFeeds() != null) {
                    feedIds = feedServiceLevelAgreementRelationship.getFeeds().stream().map(f -> f.getId())
                            .collect(Collectors.toSet());
                }

                //Update the JPA mapping in Ops Manager for this SLA and its related Feeds
                serviceLevelAgreementDescriptionProvider.updateServiceLevelAgreement(savedSla.getId(),
                        savedSla.getName(), savedSla.getDescription(), feedIds);

                com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement restModel = serviceLevelAgreementTransform
                        .toModel(savedSla, slaFeeds, true);
                //schedule it
                serviceLevelAgreementScheduler.scheduleServiceLevelAgreement(savedSla);
                return restModel;

            });
        }
    }
    return null;
}

From source file:cop.maven.plugins.AbstractRamlConfigMojoTest.java

@Test
public void testReadConfiguration() throws IOException {
    Xpp3Dom config = new Xpp3Dom("config") {
        {//from   w  w w  . ja  v a 2s. c om
            addChild(new Xpp3Dom(Config.KEY_API) {
                {
                    addChild(createDom(Config.KEY_API_TITLE, "aaa"));
                    addChild(createDom(Config.KEY_API_BASE_URI, "bbb"));
                }
            });
            addChild(new Xpp3Dom(Config.KEY_RAML) {
                {
                    addChild(createDom(Config.KEY_RAML_VERSION, "1.0"));
                }
            });
        }
    };

    mojo.mojoExecution = new MojoExecutionMock();
    mojo.mojoExecution.setConfiguration(config);

    String actual = mojo.readConfiguration();
    String expected = StringUtils.trim(TestUtils.getResourceAsString("config.yml"));
    TestUtils.assertThatEquals(actual, expected);
}

From source file:au.com.ogsoft.yahaml4j.Haml.java

/**
 * TEMPLATELINE -> ([ELEMENT][IDSELECTOR][CLASSSELECTORS][ATTRIBUTES] [SLASH|CONTENTS])|(!CONTENTS) (EOL|EOF)
 *//*from   w w w.  j  av a 2s.com*/
private void _templateLine(Tokeniser tokeniser, List<Element> elementStack, int indent, HamlGenerator generator,
        HamlOptions options) {

    if (tokeniser.getToken().type != Token.TokenType.EOL) {
        _closeElements(indent, elementStack, tokeniser, generator);
    }

    String identifier = _element(tokeniser);
    String id = _idSelector(tokeniser);
    List<String> classes = _classSelector(tokeniser);
    String objectRef = _objectReference(tokeniser);
    Map<String, String> attrList = _attributeList(tokeniser, options);

    ParsePoint currentParsePoint = tokeniser.currentParsePoint();
    Map<String, String> attributesHash = _attributeHash(tokeniser, options);

    TagOptions tagOptions = new TagOptions();
    tagOptions.selfClosingTag = false;
    tagOptions.innerWhitespace = true;
    tagOptions.outerWhitespace = true;
    boolean lineHasElement = _lineHasElement(identifier, id, classes);

    if (tokeniser.getToken().type == Token.TokenType.SLASH) {
        tagOptions.selfClosingTag = true;
        tokeniser.getNextToken();
    }
    if (tokeniser.getToken().type == Token.TokenType.GT && lineHasElement) {
        tagOptions.outerWhitespace = false;
        tokeniser.getNextToken();
    }
    if (tokeniser.getToken().type == Token.TokenType.LT && lineHasElement) {
        tagOptions.innerWhitespace = false;
        tokeniser.getNextToken();
    }

    if (lineHasElement) {
        if (!tagOptions.selfClosingTag) {
            tagOptions.selfClosingTag = _isSelfClosingTag(identifier) && !_tagHasContents(indent, tokeniser);
        }
        _openElement(currentParsePoint, indent, identifier, id, classes, objectRef, attrList, attributesHash,
                elementStack, tagOptions, generator);
    }

    boolean hasContents;
    if (tokeniser.getToken().type == Token.TokenType.WS) {
        tokeniser.getNextToken();
    }

    if (tokeniser.getToken().type == Token.TokenType.EQUAL
            || tokeniser.getToken().type == Token.TokenType.ESCAPEHTML
            || tokeniser.getToken().type == Token.TokenType.UNESCAPEHTML) {
        _embeddedCode(tokeniser, indent + 1, null, tagOptions, generator);
        hasContents = true;
    } else {
        String contents;
        boolean shouldInterpolate = false;
        if (tokeniser.getToken().type == Token.TokenType.EXCLAMATION) {
            tokeniser.getNextToken();
            contents = tokeniser.skipToEOLorEOF();
        } else {
            contents = tokeniser.skipToEOLorEOF();
            if (contents.startsWith("\\")) {
                contents = contents.substring(1);
            }
            shouldInterpolate = true;
        }

        hasContents = StringUtils.isNotEmpty(contents);
        String indentText = "";
        if (hasContents) {
            if (tagOptions.innerWhitespace && lineHasElement
                    || (!lineHasElement && _parentInnerWhitespace(elementStack, indent))) {
                indentText = HamlRuntime.indentText(identifier.length() > 0 ? indent + 1 : indent);
            } else {
                contents = StringUtils.trim(contents);
            }
            generator.appendTextContents(indentText + contents, shouldInterpolate, currentParsePoint, null);
            generator.getOutputBuffer().append(_newline(tokeniser));
        }

        _eolOrEof(tokeniser);
    }

    if (tagOptions.selfClosingTag && hasContents) {
        _handleError(options, null, tokeniser,
                new RuntimeException(HamlRuntime.templateError(currentParsePoint.lineNumber,
                        currentParsePoint.characterNumber, currentParsePoint.currentLine,
                        "A self-closing tag can not have any contents")));
    }
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.parser.GWikiWikiParser.java

protected void parseMacro(GWikiWikiTokens tks, GWikiWikiParserContext ctx) {
    int curTokePos = tks.getTokenPos();
    char tk = tks.nextToken();
    String macroName = tks.curTokenString();
    MacroAttributes ma = new MacroAttributes(macroName);
    tk = tks.nextToken();//from w w  w . j a va2  s.  c o m
    // tks.nextToken();
    GWikiMacroFragment frag = parseMacroHead(ma, tks, ctx);
    if (frag == null) {
        ctx.addTextFragement("{");
        tks.setTokenPos(curTokePos + 1);
        return;
    }
    ctx.pushFragList();
    try {
        ctx.pushFragStack(frag);
        if (frag.getMacro().hasBody() == false) {
            ctx.addFragments(ctx.popFragList());
            if (frag.getMacro() instanceof GWikiCompileTimeMacro) {
                Collection<GWikiFragment> nfrags = ((GWikiCompileTimeMacro) frag.getMacro()).getFragments(frag,
                        tks, ctx);
                ctx.addFragments(nfrags);
            } else if (frag.getMacro() instanceof GWikiRuntimeMacro) {
                ctx.addFragment(frag);
            } else {
                ctx.addFragment(
                        new GWikiFragmentParseError("Macro is neither Compile nor Runtime Macro: " + macroName,
                                tks.getLineNoFromTokenOffset(curTokePos)));
            }
            return;
        } else if (frag.getMacro() instanceof GWikiCompileTimeMacro) {
            // compile time
            Collection<GWikiFragment> nfrags = ((GWikiCompileTimeMacro) frag.getMacro()).getFragments(frag, tks,
                    ctx);
            ctx.addFragments(nfrags);
        }
        tk = tks.curToken();
        int tkn = tk;
        int startToken = tks.getTokenPos();
        if (GWikiMacroRenderFlags.TrimTextContent.isSet(frag.getMacro().getRenderModes()) == true) {
            tk = tks.skipWsNl();

        }
        if (frag.getMacro().evalBody() == true) {
            ctx.pushFragList();
            do {
                tks.addStopToken('{');
                parseMacroBody(tks, ctx);
                tk = tks.curToken(true);
                if (tk == '{') {
                    if (tks.peekToken(1, true) == '{') {
                        tks.removeStopToken('{');
                        parseWords(tks, ctx);
                        tks.addStopToken('{');
                        continue;
                    }
                    int tkss = tks.getTokenPos();
                    tks.nextToken();
                    String nmacroName = tks.curTokenString();
                    if (nmacroName.equals(macroName) == false) {
                        tks.setTokenPos(tkss);
                        tks.removeStopToken('{');
                        parseMacro(tks, ctx);
                        continue;
                    }
                    tks.nextToken();
                    MacroAttributes nma = new MacroAttributes(nmacroName);
                    GWikiMacroFragment nmf = parseMacroHead(nma, tks, ctx);
                    if (nmf.getAttrs().getArgs().isEmpty() == true) {
                        tks.removeStopToken('{');
                        break;
                    }
                    tks.setTokenPos(tkss);
                    tks.removeStopToken('{');
                    parseMacro(tks, ctx);
                    continue;
                } else {
                    List<GWikiFragment> body = ctx.popFragList();
                    String source = frag.getSource();
                    ctx.addFragment(
                            new GWikiFragmentParseError("Missing macro end for  " + macroName + "; " + source,
                                    tks.getLineNoFromTokenOffset(curTokePos)));
                    ctx.addFragments(body);
                    ctx.addFragments(ctx.popFragList());
                    return;
                }
            } while (true);

            List<GWikiFragment> childs = ctx.popFragList();
            if (GWikiMacroRenderFlags.TrimTextContent.isSet(frag.getMacro().getRenderModes()) == true) {
                childs = removeWsTokensFromEnd(childs);
            }
            if (GWikiMacroRenderFlags.ContainsTextBlock.isSet(frag.getMacro().getRenderModes()) == true
                    && isPAllowedInDom(ctx)) {
                // TODO frisst P
                childs = addWrappedP(childs);
            }
            frag.addChilds(childs);
            ma.setChildFragment(new GWikiFragmentChildContainer(frag.getChilds()));
            if (GWikiMacroRenderFlags.TrimWsAfter.isSet(frag.getMacro().getRenderModes()) == true) {
                tks.skipWsNl();
            }
        } else {
            int endToken = tks.findToken("{", frag.getAttrs().getCmd(), "}");
            if (endToken == -1) {
                List<GWikiFragment> fragl = ctx.popFragList();
                ctx.addFragment(new GWikiFragmentParseError("Missing macro end for  " + macroName,
                        tks.getLineNoFromTokenOffset(curTokePos)));
                ctx.addFragments(fragl);
                endToken = tks.getLastToken();
                String body = tks.getTokenString(startToken, endToken);
                ctx.addFragment(new GWikiFragmentText(body));
                return;
            }
            String body = tks.getTokenString(startToken, endToken);
            if (GWikiMacroRenderFlags.TrimTextContent.isSet(frag.getMacro().getRenderModes()) == true) {
                body = StringUtils.trim(body);
            }
            frag.getAttrs().setBody(body);
            tks.setTokenPos(endToken + 3);
        }
        ctx.addFragments(ctx.popFragList());
        if (frag.getMacro() instanceof GWikiCompileTimeMacro) {
            // ctx.addFragments(((GWikiCompileTimeMacro) frag.getMacro()).getFragments(frag, tks, ctx));
        } else if (frag.getMacro() instanceof GWikiRuntimeMacro) {
            ctx.addFragment(frag);
        } else {
            ctx.addFragment(
                    new GWikiFragmentParseError("Macro is neither Compile nor Runtime Macro: " + macroName,
                            tks.getLineNoFromTokenOffset(curTokePos)));
        }
    } finally {
        ctx.popFragStack();
    }
}

From source file:com.hubrick.vertx.s3.client.S3Client.java

private InitMultipartUploadRequest mapAdaptiveUploadRequestToInitMultipartUploadRequest(
        AdaptiveUploadRequest autoUploadRequest) {
    final InitMultipartUploadRequest initMultipartUploadRequest = new InitMultipartUploadRequest();

    initMultipartUploadRequest.withCacheControl(autoUploadRequest.getCacheControl());
    initMultipartUploadRequest.withContentDisposition(autoUploadRequest.getContentDisposition());
    initMultipartUploadRequest.withContentEncoding(autoUploadRequest.getContentEncoding());
    initMultipartUploadRequest.withContentType(autoUploadRequest.getContentType());
    initMultipartUploadRequest.withExpires(autoUploadRequest.getExpires());

    for (Map.Entry<String, String> meta : autoUploadRequest.getAmzMeta()) {
        initMultipartUploadRequest.withAmzMeta(meta.getKey(), StringUtils.trim(meta.getValue()));
    }//from   w  w w  . ja  va  2  s .com

    initMultipartUploadRequest.withAmzStorageClass(autoUploadRequest.getAmzStorageClass());
    initMultipartUploadRequest
            .withAmzWebsiteRedirectLocation(autoUploadRequest.getAmzWebsiteRedirectLocation());
    initMultipartUploadRequest.withAmzAcl(autoUploadRequest.getAmzAcl());
    initMultipartUploadRequest.withAmzGrantRead(autoUploadRequest.getAmzGrantRead());
    initMultipartUploadRequest.withAmzGrantWrite(autoUploadRequest.getAmzGrantWrite());
    initMultipartUploadRequest.withAmzGrantWriteAcp(autoUploadRequest.getAmzGrantWriteAcp());
    initMultipartUploadRequest.withAmzGrantRead(autoUploadRequest.getAmzGrantRead());
    initMultipartUploadRequest.withAmzGrantReadAcp(autoUploadRequest.getAmzGrantReadAcp());
    initMultipartUploadRequest.withAmzGrantFullControl(autoUploadRequest.getAmzGrantFullControl());

    return initMultipartUploadRequest;
}

From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineFactory.java

/**
 * Initializes a {@link StreamingMessageQueue} instance according to provided information.
 * @param queueConfiguration+//from   ww  w .ja v  a  2 s . c o m
 * @return
 * @throws RequiredInputMissingException
 * @throws QueueInitializationFailedException
 */
protected StreamingMessageQueue initializeQueue(final StreamingMessageQueueConfiguration queueConfiguration)
        throws RequiredInputMissingException, QueueInitializationFailedException {

    ///////////////////////////////////////////////////////////////////////////////////
    // validate input
    if (queueConfiguration == null)
        throw new RequiredInputMissingException("Missing required queue configuration");
    if (StringUtils.isBlank(queueConfiguration.getId()))
        throw new RequiredInputMissingException("Missing required queue identifier");
    //
    ///////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////
    // check properties for optional settings
    boolean inMemoryQueue = false;
    if (queueConfiguration.getProperties() != null && !queueConfiguration.getProperties().isEmpty()) {
        String queueType = StringUtils.lowerCase(StringUtils
                .trim(queueConfiguration.getProperties().getProperty(StreamingMessageQueue.CFG_QUEUE_TYPE)));
        inMemoryQueue = StringUtils.equalsIgnoreCase(queueType, InMemoryStreamingMessageQueue.CFG_QUEUE_TYPE);
    }
    ///////////////////////////////////////////////////////////////////////////////////

    if (inMemoryQueue) {
        try {
            StreamingMessageQueue queue = new InMemoryStreamingMessageQueue();
            queue.setId(StringUtils.lowerCase(StringUtils.trim(queueConfiguration.getId())));
            queue.initialize((queueConfiguration.getProperties() != null ? queueConfiguration.getProperties()
                    : new Properties()));
            return queue;
        } catch (Exception e) {
            throw new QueueInitializationFailedException("Failed to initialize streaming message queue '"
                    + queueConfiguration.getId() + "'. Error: " + e.getMessage());
        }
    }

    try {
        StreamingMessageQueue queue = new DefaultStreamingMessageQueue();
        queue.setId(StringUtils.lowerCase(StringUtils.trim(queueConfiguration.getId())));
        queue.initialize((queueConfiguration.getProperties() != null ? queueConfiguration.getProperties()
                : new Properties()));
        return queue;
    } catch (Exception e) {
        throw new QueueInitializationFailedException("Failed to initialize streaming message queue '"
                + queueConfiguration.getId() + "'. Error: " + e.getMessage());
    }
}

From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionParser.java

public SearchExpression parse(String pattern) {
    pattern = StringUtils.trim(pattern);
    List<TokenResult> tokenResults = TextSplitterUtils.parseStringTokens(pattern, DefaultToken, escapeChar,
            true, true);//from  w w  w  .  ja v a  2  s.  c o  m
    TokenResultList tkl = new TokenResultList(tokenResults, 0, pattern);
    SearchExpression ret = consume(tkl);
    if (tkl.eof() == false) {
        throw new InvalidMatcherGrammar(
                "unconsumed tokens. pattern: " + pattern + "; rest: " + tkl.restOfTokenString());
    }
    return ret;
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Constructs the MessageFilter (this.filter) based on the current form selections
 *//*from  w ww  .ja  v a  2 s. com*/
private boolean generateMessageFilter() {
    messageFilter = new MessageFilter();

    // set start/end date
    try {
        messageFilter.setStartDate(getCalendar(mirthDatePicker1, mirthTimePicker1));
        Calendar endCalendar = getCalendar(mirthDatePicker2, mirthTimePicker2);

        if (endCalendar != null && !mirthTimePicker2.isEnabled()) {
            // If the end time picker is disabled, it will be set to 00:00:00 of the day provided.
            // Since our query is using <= instead of <, we add one day and then subtract a millisecond 
            // in order to set the time to the last millisecond of the day we want to search on
            endCalendar.add(Calendar.DATE, 1);
            endCalendar.add(Calendar.MILLISECOND, -1);
        }
        messageFilter.setEndDate(endCalendar);
    } catch (ParseException e) {
        parent.alertError(parent, "Invalid date.");
        return false;
    }

    Calendar startDate = messageFilter.getStartDate();
    Calendar endDate = messageFilter.getEndDate();

    if (startDate != null && endDate != null && startDate.getTimeInMillis() > endDate.getTimeInMillis()) {
        parent.alertError(parent, "Start date cannot be after the end date.");
        return false;
    }

    // Set text search
    String textSearch = StringUtils.trim(textSearchField.getText());

    if (textSearch.length() > 0) {
        messageFilter.setTextSearch(textSearch);
        List<String> textSearchMetaDataColumns = new ArrayList<String>();

        for (MetaDataColumn metaDataColumn : getMetaDataColumns()) {
            if (metaDataColumn.getType() == MetaDataColumnType.STRING) {
                textSearchMetaDataColumns.add(metaDataColumn.getName());
            }
        }

        messageFilter.setTextSearchMetaDataColumns(textSearchMetaDataColumns);
    }

    if (regexTextSearchCheckBox.isSelected()) {
        messageFilter.setTextSearchRegex(true);
    }

    // set status
    Set<Status> statuses = new HashSet<Status>();

    if (statusBoxReceived.isSelected()) {
        statuses.add(Status.RECEIVED);
    }

    if (statusBoxTransformed.isSelected()) {
        statuses.add(Status.TRANSFORMED);
    }

    if (statusBoxFiltered.isSelected()) {
        statuses.add(Status.FILTERED);
    }

    if (statusBoxSent.isSelected()) {
        statuses.add(Status.SENT);
    }

    if (statusBoxError.isSelected()) {
        statuses.add(Status.ERROR);
    }

    if (statusBoxQueued.isSelected()) {
        statuses.add(Status.QUEUED);
    }

    if (!statuses.isEmpty()) {
        messageFilter.setStatuses(statuses);
    }

    if (StringUtils.isNotEmpty(textSearch)
            && Preferences.userNodeForPackage(Mirth.class).getBoolean("textSearchWarning", true)) {
        JCheckBox dontShowTextSearchWarningCheckBox = new JCheckBox(
                "Don't show this message again in the future");

        String textSearchWarning = "<html>Text searching may take a long time, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>";
        String textRegexSearchWarning = "<html>Regular expression pattern matching may take a long time and be a costly operation, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>";
        String searchWarning = (regexTextSearchCheckBox.isSelected()) ? textRegexSearchWarning
                : textSearchWarning;
        Object[] params = new Object[] { searchWarning, dontShowTextSearchWarningCheckBox };
        int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        Preferences.userNodeForPackage(Mirth.class).putBoolean("textSearchWarning",
                !dontShowTextSearchWarningCheckBox.isSelected());

        if (result != JOptionPane.YES_OPTION) {
            return false;
        }
    }

    advancedSearchPopup.applySelectionsToFilter(messageFilter);
    selectedMetaDataIds = messageFilter.getIncludedMetaDataIds();

    if (messageFilter.getMaxMessageId() == null) {
        try {
            Long maxMessageId = parent.mirthClient.getMaxMessageId(channelId);
            messageFilter.setMaxMessageId(maxMessageId);
        } catch (ClientException e) {
            parent.alertThrowable(parent, e);
            return false;
        }
    }

    return true;
}

From source file:com.squid.kraken.v4.api.core.ServiceUtils.java

/**
 * Get the "real" remote host IP using X-Forwarded-For http header.
 * @param req/*from  w  ww.  jav a  2  s.  c  o  m*/
 * @return forwarded IP or remote host if no xff header found
 */
public String getRemoteIP(HttpServletRequest req) {
    String reqIp;
    // check if we have a X-Forwarded-For header (if we're behind a proxy)
    final String xff = req.getHeader(HEADER_XFF);
    if (xff != null) {
        // default if xff
        reqIp = xff;
        // get the right-most non private IP address
        StringTokenizer st = new StringTokenizer(xff, ",");
        while (st.hasMoreTokens()) {
            String tok = StringUtils.trim(st.nextToken());
            if ((!tok.startsWith(PRIVATE_IP_PREFIX_AWS)) && (!tok.startsWith(PRIVATE_IP_PREFIX_SQUID))) {
                reqIp = tok;
            }
        }
    } else {
        // use the normal remote IP
        reqIp = req.getRemoteAddr();
    }
    return reqIp;
}