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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:com.adeptj.runtime.server.IdentityManagers.java

/**
 * Verify the given credentials./* w w  w.  j  a  v  a 2 s. c o  m*/
 *
 * @param username   one from configs.
 * @param id         one that is submitted by client.
 * @param credential the submitted user credential.
 * @return boolean to indicate whether the credentials verification was successful or not.
 */
private static boolean doVerifyCredentials(String username, String id, Credential credential) {
    PasswordCredential pc = (PasswordCredential) credential;
    return StringUtils.equals(username, id) && ArrayUtils.isNotEmpty(pc.getPassword())
            && CredentialMatcher.match(username, pc.getPassword());
}

From source file:models.PullRequestEvent.java

private static boolean needToDeleteEvent(PullRequestEvent lastEvent, PullRequestEvent currentEvent) {
    return lastEvent != null && currentEvent.eventType == EventType.PULL_REQUEST_REVIEW_STATE_CHANGED
            && lastEvent.eventType == EventType.PULL_REQUEST_REVIEW_STATE_CHANGED
            && StringUtils.equals(currentEvent.senderLoginId, lastEvent.senderLoginId);
}

From source file:ch.cyberduck.core.idna.PunycodeConverter.java

/**
 * @return IDN normalized hostname/*from   ww w  .  ja  v a 2 s.  c o  m*/
 */
public String convert(final String hostname) {
    if (!PreferencesFactory.get().getBoolean("connection.hostname.idn")) {
        return StringUtils.strip(hostname);
    }
    if (StringUtils.isNotEmpty(hostname)) {
        try {
            // Convenience function that implements the IDNToASCII operation as defined in
            // the IDNA RFC. This operation is done on complete domain names, e.g: "www.example.com".
            // It is important to note that this operation can fail. If it fails, then the input
            // domain name cannot be used as an Internationalized Domain Name and the application
            // should have methods defined to deal with the failure.
            // IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
            // and do not use STD3 ASCII rules If unassigned code points are found
            // the operation fails with ParseException
            final String idn = IDN.toASCII(StringUtils.strip(hostname));
            if (log.isDebugEnabled()) {
                if (!StringUtils.equals(StringUtils.strip(hostname), idn)) {
                    log.debug(String.format("IDN hostname for %s is %s", hostname, idn));
                }
            }
            if (StringUtils.isNotEmpty(idn)) {
                return idn;
            }
        } catch (IllegalArgumentException e) {
            log.warn(String.format("Failed to convert hostname %s to IDNA", hostname), e);
        }
    }
    return StringUtils.strip(hostname);
}

From source file:de.micromata.genome.gwiki.controls.GWikiPluginDownloadActionBean.java

public static String getDetailPage(GWikiContext wikiContext, GWikiPluginDescriptor pdesc) {
    String pluginId = pdesc.getPluginId();
    String parenPageId = "gwikidocs/plugins/en/GWiki_Plugins";
    GWikiElementInfo pei = wikiContext.getWikiWeb().findElementInfo(parenPageId);
    if (pei == null) {
        return null;
    }/*from   www  .j av  a 2  s.  c  o  m*/
    for (GWikiElementInfo ei : wikiContext.getElementFinder().getAllDirectChilds(pei)) {
        String id = ei.getId();
        String n = FileNameUtils.getNamePart(id);
        if (StringUtils.equals(n, pluginId) == true) {
            return id;
        }
    }
    return null;
}

From source file:net.sf.appstatus.web.pages.AbstractPage.java

protected String getPage(StatusWebHandler webHandler, Map<String, String> valueMap)
        throws UnsupportedEncodingException, IOException {

    valueMap.put("css", "<link href=\"" + webHandler.getCssLocation() + "\" rel=\"stylesheet\">");

    valueMap.put("UrlAppStatus", URL);

    StrBuilder menu = new StrBuilder();
    for (String pageId : webHandler.getPages().keySet()) {
        IPage page = webHandler.getPages().get(pageId);
        if (StringUtils.equals(pageId, getId())) {
            menu.append("<li class=active>");
        } else {/*ww w.  j  a v a 2 s.c o m*/
            menu.append("<li>");
        }
        menu.append("<a href=\"?p=" + page.getId() + "\">" + page.getName() + "</a></li>");
    }
    valueMap.put("menu", menu.toString());
    valueMap.put("applicationName", webHandler.getApplicationName());

    return HtmlUtils.applyLayout(valueMap, PAGELAYOUT);

}

From source file:io.wcm.handler.media.spi.helpers.AbstractMediaSource.java

@Override
public boolean accepts(MediaRequest mediaRequest) {
    // if an explicit media request is set check this first
    if (StringUtils.isNotEmpty(mediaRequest.getMediaRef())) {
        return accepts(mediaRequest.getMediaRef());
    }//from   w ww . j  a  va 2  s  .com
    // otherwise check resource which contains media request properties
    ValueMap props = mediaRequest.getResourceProperties();
    // check for matching media source ID in link resource
    String mediaSourceId = props.get(MediaNameConstants.PN_MEDIA_SOURCE, String.class);
    if (StringUtils.isNotEmpty(mediaSourceId)) {
        return StringUtils.equals(mediaSourceId, getId());
    }
    // if not link type is set at all check if link ref attribute contains a valid link
    else {
        String refProperty = StringUtils.defaultString(mediaRequest.getRefProperty(),
                getPrimaryMediaRefProperty());
        String mediaRef = props.get(refProperty, String.class);
        return accepts(mediaRef);
    }
}

From source file:io.wcm.samples.handler.controller.http.Redirect.java

@PostConstruct
protected void activate() throws IOException {
    // resolve link of redirect page
    String redirectUrl = linkHandler.get(resource).buildUrl();

    // in preview/publish mode redirect to target
    if ((wcmMode == WCMMode.DISABLED || wcmMode == WCMMode.PREVIEW) && StringUtils.isNotEmpty(redirectUrl)) {
        if (StringUtils.equals(redirectStatus, "301")) {
            response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
            response.setHeader("Location", redirectUrl);
        } else {//from   w  w  w  . j a  v a  2s.  com
            response.sendRedirect(redirectUrl);
        }
        renderPage = false;
    } else if (wcmMode == WCMMode.DISABLED) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        renderPage = false;
    }
}

From source file:com.xpn.xwiki.internal.velocity.DefaultVelocityEvaluator.java

@Override
public String evaluateVelocity(String content, String namespace, VelocityContext vcontext)
        throws XWikiException {
    StringWriter writer = new StringWriter();

    boolean renderingContextPushed = false;
    try {/*from   ww w  .ja v  a 2 s  . co m*/
        // Switch current namespace if needed
        String currentNamespace = renderingContext.getTransformationId();
        if (namespace != null && !StringUtils.equals(namespace, currentNamespace)) {
            if (renderingContext instanceof MutableRenderingContext) {
                // Make the current velocity template id available
                ((MutableRenderingContext) renderingContext).push(renderingContext.getTransformation(),
                        renderingContext.getXDOM(), renderingContext.getDefaultSyntax(), namespace,
                        renderingContext.isRestricted(), renderingContext.getTargetSyntax());

                renderingContextPushed = true;
            }
        }

        velocityManager.getVelocityEngine().evaluate(vcontext, writer, namespace, content);

        return writer.toString();
    } catch (Exception e) {
        Object[] args = { namespace };
        throw new XWikiException(XWikiException.MODULE_XWIKI_RENDERING,
                XWikiException.ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION,
                "Error while parsing velocity page {0}", e, args);
    } finally {
        // Get rid of temporary rendering context
        if (renderingContextPushed) {
            ((MutableRenderingContext) this.renderingContext).pop();
        }
    }
}

From source file:com.sixt.service.framework.configuration.ConfigurationManager.java

public synchronized void processValues(Map<String, String> updatedValues) {
    updatedValues.keySet().stream().forEach(key -> {
        String newValue = updatedValues.get(key);
        //process only new or updated values
        if (!StringUtils.equals(newValue, lastProperties.get(key))) {
            lastProperties.put(key, newValue);
            notifyListeners(key, newValue);

            //(allows command-line overrides)
            serviceProps.addProperty(key, newValue);
        }//from ww  w  . jav a 2s  .c om
    });
    dataReceived.set(true);
    startupLatch.countDown();
}

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

License:asdf

void testConvert(String html, String wiki) {
    GWikiTestBuilder tb = new GWikiTestBuilder();
    GWikiContext ctx = tb.createWikiContext();
    try {/*from w  w w.  j  a v a2 s. co m*/
        String ret = rteToWiki(ctx, html);
        System.out.println("html:\n" + html + "\nwiki:\n[" + ret + "]");
        if (StringUtils.equals(wiki, ret) == false) {
            System.out.println("expect wiki:\n[" + wiki + "]");
        }
        Assert.assertEquals(wiki, ret);
    } catch (RuntimeException ex) {
        ex.printStackTrace();
        throw ex;
    }
}