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

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

Introduction

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

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:com.bluexml.xforms.messages.MsgPool.java

/**
 * Returns the string that is associated to a key in the messages file. The string may be empty
 * but a null value is never returned./*from  w  w w. j a va 2  s.c o m*/
 * 
 * @param msgKey
 *            the key, either an enum from class MsgId or a String
 * @return the string attached to the key
 */
public static String getMsg(Object msgKey, String... args) {
    String theKey = null;

    if (msgKey instanceof MsgId) {
        MsgId theMsgId = (MsgId) msgKey;
        theKey = theMsgId.getText();
    } else if (msgKey instanceof String) {
        theKey = (String) msgKey;
    }

    getInstance();
    String res = MsgPool.getPool().getProperty(theKey);
    if (res != null) {
        return replaceArgs(res, args);
    }
    // a key may be set to an empty string in the properties file
    if (hasProperty(theKey) == true) {
        return "";
    }
    if (logger.isWarnEnabled()) {
        logger.warn("Message not found for key: " + theKey);
    }
    if (StringUtils.equals(theKey, MsgId.MSG_KEY_NOT_FOUND.getText())) {
        return MsgId.INT_MSGPOOL_NO_MESSAGE_FILE.getText();
    }
    return MsgPool.getMsg(MsgId.MSG_KEY_NOT_FOUND);
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.runtimeproperty.RunTimePropertyCellModifier.java

/**
 * Modifies the element//from  w w w .  j a  va2 s  .  c o m
 * 
 * @param element
 *            the element
 * @param property
 *            the property
 * @param value
 *            the value
 */
public void modify(Object element, String property, Object value) {
    if (viewer.getData(Constants.WINDOW_TITLE) != null && StringUtils
            .equalsIgnoreCase((String) viewer.getData(Constants.WINDOW_TITLE), Constants.SUBJOB_WINDOW_LABEL))
        customizedModifyForSubgraph(element, property, value);
    else {
        if (element instanceof Item)
            element = ((Item) element).getData();

        RuntimeProperties runtimePropertyRow = (RuntimeProperties) element;

        if (StringUtils.equals(PROPERTY_NAME, property)) {
            if (ParameterUtil.isParameter((String) value)) {
                runtimePropertyRow.setPropertyValue((String) value);
            }
            runtimePropertyRow.setPropertyName(((String) value));
        } else if (StringUtils.equals(PROPERTY_VALUE, property)) {
            if (ParameterUtil.isParameter((String) value)) {
                runtimePropertyRow.setPropertyName((String) value);
            }
            runtimePropertyRow.setPropertyValue((String) value);
        }
    }
    // Force the viewer to refresh
    viewer.refresh();
}

From source file:com.nagarro.core.oauth2.token.provider.HybrisOAuthTokenStore.java

@Override
public OAuth2AccessToken getAccessToken(final OAuth2Authentication authentication) {
    OAuth2AccessToken accessToken = null;
    OAuthAccessTokenModel accessTokenModel = null;
    final String authenticationId = authenticationKeyGenerator.extractKey(authentication);
    try {//  w w  w .  j a v a 2s. co m
        accessTokenModel = oauthTokenService.getAccessTokenForAuthentication(authenticationId);
        accessToken = deserializeAccessToken((byte[]) accessTokenModel.getToken());
    } catch (final ClassCastException e) {
        LOG.warn("Could not extract access token for authentication " + authentication);
        oauthTokenService.removeAccessTokenForAuthentication(authenticationId);
    } catch (final UnknownIdentifierException e) {
        if (LOG.isInfoEnabled()) {
            LOG.debug("Failed to find access token for authentication " + authentication);
        }
    }

    if (accessToken != null && accessTokenModel != null
            && !StringUtils.equals(authenticationId, authenticationKeyGenerator
                    .extractKey(deserializeAuthentication((byte[]) accessTokenModel.getAuthentication())))) {
        removeAccessToken(accessToken.getValue());
        // Keep the store consistent (maybe the same user is represented by this authentication but the details have
        // changed)
        storeAccessToken(accessToken, authentication);
    }
    return accessToken;
}

From source file:hydrograph.ui.common.util.TransformMappingFeatureUtility.java

public void highlightInputAndOutputFields(Text text, TableViewer inputFieldTableViewer,
        TableViewer outputFieldViewer, TransformMapping transformMapping,
        List<FilterProperties> finalSortedList) {
    Table inputtable = inputFieldTableViewer.getTable();
    Table outputTable = outputFieldViewer.getTable();

    if (text != null) {
        MappingSheetRow mappingSheetRow = null;
        setForegroundColorToBlack(inputtable, outputTable);
        for (MappingSheetRow mappingSheetRowIterate : transformMapping.getMappingSheetRows()) {
            if (StringUtils.equals(text.getText(), mappingSheetRowIterate.getOperationID())) {
                mappingSheetRow = mappingSheetRowIterate;
                break;
            }//from   ww  w.  j  a v a  2  s . com
        }
        if (mappingSheetRow != null) {
            for (FilterProperties filterProperties : mappingSheetRow.getInputFields()) {
                for (TableItem tableItem : inputtable.getItems()) {

                    if (StringUtils.equalsIgnoreCase(tableItem.getText(), filterProperties.getPropertyname())) {
                        tableItem.setForeground(CustomColorRegistry.INSTANCE.getColorFromRegistry(0, 128, 255));
                        break;
                    }
                }
            }
        }
        List<FilterProperties> templist = getObjectReferencePresentInOutputTable(finalSortedList,
                mappingSheetRow);
        for (FilterProperties filterProperties : mappingSheetRow.getOutputList()) {
            for (TableItem tableItem : outputTable.getItems()) {

                if (StringUtils.equalsIgnoreCase(tableItem.getText(), filterProperties.getPropertyname())
                        && templist.contains(filterProperties)) {
                    tableItem.setForeground(CustomColorRegistry.INSTANCE.getColorFromRegistry(0, 128, 255));
                    break;
                }
            }
        }

    } else {
        setForegroundColorToBlack(inputtable, outputTable);
    }
}

From source file:com.evolveum.midpoint.repo.sql.query.QueryContext.java

public void addAlias(ItemPath path, String alias) {
    if (aliases.containsKey(path)) {
        if (!StringUtils.equals(alias, aliases.get(path))) {
            throw new IllegalArgumentException("Path '" + path + "' (" + alias
                    + ") is already defined in alias map with alias (" + aliases.get(path) + ").");
        }/*from  ww  w .  j a  v  a2  s  . c  o  m*/

        return;
    }

    aliases.put(path, alias);
}

From source file:com.assemblade.opendj.model.authentication.policy.LdapPassthroughAuthenticationPolicy.java

@Override
public boolean requiresUpdate(Entry currentEntry) {
    return super.requiresUpdate(currentEntry)
            || !StringUtils.equals(getPrimaryRemoteServer(),
                    LdapUtils.getSingleAttributeStringValue(
                            currentEntry.getAttribute("ds-cfg-primary-remote-ldap-server")))
            || !StringUtils.equals(getSearchCriteria(),
                    LdapUtils.getSingleAttributeStringValue(
                            currentEntry.getAttribute("ds-cfg-mapped-search-base-dn")))
            || !StringUtils.equals(getBindDn(),
                    LdapUtils.getSingleAttributeStringValue(
                            currentEntry.getAttribute("ds-cfg-mapped-search-bind-dn")))
            || !StringUtils.equals(getBindPassword(), LdapUtils.getSingleAttributeStringValue(
                    currentEntry.getAttribute("ds-cfg-mapped-search-bind-password")));
}

From source file:ddf.ldap.ldaplogin.KeystoreManager.java

@Override
public void configurationUpdateCallback(Map<String, String> props) {
    LOGGER.debug("Got a new configuration.");
    String keystoreLocation = props.get(ConfigurationManager.KEY_STORE);
    String keystorePassword = encryptService.decryptValue(props.get(ConfigurationManager.KEY_STORE_PASSWORD));

    String truststoreLocation = props.get(ConfigurationManager.TRUST_STORE);
    String truststorePassword = encryptService
            .decryptValue(props.get(ConfigurationManager.TRUST_STORE_PASSWORD));

    if (StringUtils.isNotBlank(keystoreLocation) && (!StringUtils.equals(this.keystoreLoc, keystoreLocation)
            || !StringUtils.equals(this.keystorePass, keystorePassword))) {
        if (new File(keystoreLocation).exists()) {
            LOGGER.debug(/*  w w w  .  ja  v  a 2s  .c o m*/
                    "Detected a change in the values for the keystore, registering new keystore instance.");
            keystoreRegistration = registerKeystore("ks", keystoreLocation, keystorePassword,
                    keystoreRegistration);
            this.keystoreLoc = keystoreLocation;
            this.keystorePass = keystorePassword;
        } else {
            LOGGER.debug("Keystore file does not exist at location {}, not updating keystore values.");
        }
    }
    if (StringUtils.isNotBlank(truststoreLocation)
            && (!StringUtils.equals(this.truststoreLoc, truststoreLocation)
                    || !StringUtils.equals(this.truststorePass, truststorePassword))) {
        if (new File(truststoreLocation).exists()) {
            LOGGER.debug(
                    "Detected a change in the values for the truststore, registering new keystore instance.");
            truststoreRegistration = registerKeystore("ts", truststoreLocation, truststorePassword,
                    truststoreRegistration);
            this.truststoreLoc = truststoreLocation;
            this.truststorePass = truststorePassword;
        } else {
            LOGGER.debug("Truststore file does not exist at location {}, not updating truststore values.");
        }
    }

}

From source file:edu.arizona.kra.kim.ldap.EntityAffiliationMapper.java

List<EntityAffiliation.Builder> mapBuilderFromContext(DirContextOperations context) {
    List<EntityAffiliation.Builder> retval = new ArrayList<EntityAffiliation.Builder>();
    final String primaryAffiliationProperty = getConstants().getPrimaryAffiliationLdapProperty();
    final String affiliationProperty = getConstants().getAffiliationLdapProperty();
    debug("Got affiliation ", context.getStringAttribute(primaryAffiliationProperty));
    debug("Got affiliation ", context.getStringAttribute(affiliationProperty));

    String primaryAffiliation = context.getStringAttribute(primaryAffiliationProperty);

    int affiliationId = 1;
    String affiliationCode = getAffiliationTypeCodeForName(primaryAffiliation);

    final EntityAffiliation.Builder aff1 = EntityAffiliation.Builder.create();
    aff1.setAffiliationType(//from  www.  j  a v  a2 s .co  m
            EntityAffiliationType.Builder.create(affiliationCode == null ? "AFLT" : affiliationCode));
    aff1.setCampusCode(getConstants().getDefaultCampusCode());
    aff1.setId("" + affiliationId++);
    aff1.setDefaultValue(true);
    aff1.setActive(true);
    retval.add(aff1);

    String[] affiliations = context.getStringAttributes(affiliationProperty);
    // Create an empty array to prevent NPE
    if (affiliations == null) {
        affiliations = new String[] {};
    }

    for (String affiliation : affiliations) {
        if (!StringUtils.equals(affiliation, primaryAffiliation)) {
            affiliationCode = getAffiliationTypeCodeForName(affiliation);
            if (affiliationCode != null && !hasAffiliation(retval, affiliationCode)) {
                final EntityAffiliation.Builder aff = EntityAffiliation.Builder.create();
                aff.setAffiliationType(EntityAffiliationType.Builder.create(affiliationCode));
                aff.setCampusCode(getConstants().getDefaultCampusCode());
                aff.setId("" + affiliationId++);
                aff.setDefaultValue(false);
                aff.setActive(true);
                retval.add(aff);
            }
        }
    }

    return retval;
}

From source file:cec.easyshop.storefront.security.StorefrontAuthenticationSuccessHandlerTest.java

@Test
public void shouldContinueToDefaultUrl() {
    BDDMockito.given(request.getAttribute(CART_MERGED)).willReturn(Boolean.TRUE);
    BDDMockito.doReturn(Boolean.FALSE).when(authenticationSuccessHandler).isAlwaysUseDefaultTargetUrl();
    authenticationSuccessHandler.setDefaultTargetUrl("/im/a/default/");

    Assert.assertTrue(StringUtils.equals("/im/a/default/",
            authenticationSuccessHandler.determineTargetUrl(request, response)));
}