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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String irrespective of case, handling null.

Usage

From source file:org.digidoc4j.impl.bdoc.BDocContainerTest.java

private int countResponderCertIdInsCertificateValues(Element certificateValues) {
    int responderCertCount = 0;
    NodeList certificates = certificateValues.getChildNodes();
    for (int i = 0; i < certificates.getLength(); i++) {
        Node cert = certificates.item(i);
        Node certId = cert.getAttributes().getNamedItem("Id");
        if (certId != null) {
            String idValue = certId.getNodeValue();
            if (StringUtils.containsIgnoreCase(idValue, "RESPONDER_CERT")) {
                responderCertCount++;//  ww  w.j  ava2 s. c o m
            }
        }
    }
    return responderCertCount;
}

From source file:org.drugis.addis.imports.ClinicaltrialsImporter.java

private static BasicMeasurement createBasicRateMeasurement(MeasurementStruct totalStruct,
        MeasurementStruct rateStruct, MeasureStruct rateMeasure) {
    return buildRateMeasurement(totalStruct.valueAttribute, rateStruct.valueAttribute,
            StringUtils.containsIgnoreCase(rateMeasure.units, "Percentage"));
}

From source file:org.dspace.app.cris.integration.BindItemToRP.java

public static int automaticClaim(Context context, ResearcherPage rp) throws SQLException, AuthorizeException {
    context.turnOffAuthorisationSystem();

    DSpace dspace = new DSpace();
    ApplicationService applicationService = dspace.getServiceManager().getServiceByName("applicationService",
            ApplicationService.class);

    RelationPreferenceService relationPreferenceService = dspace.getServiceManager().getServiceByName(
            "org.dspace.app.cris.service.RelationPreferenceService", RelationPreferenceService.class);

    List<RelationPreference> rejected = new ArrayList<RelationPreference>();
    for (RelationPreferenceConfiguration configuration : relationPreferenceService.getConfigurationService()
            .getList()) {/*from ww w. j  a va2  s.c o m*/
        if (configuration.getRelationConfiguration().getRelationClass().equals(Item.class)) {
            rejected = applicationService.findRelationsPreferencesByUUIDByRelTypeAndStatus(rp.getUuid(),
                    configuration.getRelationConfiguration().getRelationName(), RelationPreference.UNLINKED);
        }
    }

    EPerson eperson = EPerson.find(context, rp.getEpersonID());
    ItemIterator items = Item.findBySubmitter(context, eperson);
    List<MetadataField> mfs = metadataFieldWithAuthorityRP(context);
    int count = 0;
    while (items.hasNext()) {
        Item item = items.next();
        if (rejected == null || !rejected.contains(item.getID())) {
            boolean found = false;
            for (MetadataField mf : mfs) {
                String schema = MetadataSchema.find(context, mf.getSchemaID()).getName();
                String element = mf.getElement();
                String qualifier = mf.getQualifier();
                DCValue[] values = item.getMetadata(schema, element, qualifier, Item.ANY);
                item.clearMetadata(schema, element, qualifier, Item.ANY);

                for (DCValue val : values) {
                    if (val.authority == null && val.value != null
                            && StringUtils.containsIgnoreCase(val.value, eperson.getLastName().trim())) {
                        val.authority = ResearcherPageUtils.getPersistentIdentifier(rp);
                        val.confidence = Choices.CF_ACCEPTED;
                        found = true;
                    }
                    item.addMetadata(schema, element, qualifier, val.language, val.value, val.authority,
                            val.confidence);
                }
            }
            if (found) {
                item.update();
                count++;
            }
        }
    }
    context.restoreAuthSystemState();
    return count;
}

From source file:org.dspace.authenticate.LDAPAuthentication.java

private void assignGroupsBasedOnLdapDn(String dn, Context context) {
    if (StringUtils.isNotBlank(dn)) {
        System.out.println("dn:" + dn);
        int i = 1;
        String groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + i);
        while (groupMap != null) {
            String t[] = groupMap.split(":");
            String ldapSearchString = t[0];
            String dspaceGroupName = t[1];

            if (StringUtils.containsIgnoreCase(dn, ldapSearchString)) {
                // assign user to this group   
                try {
                    Group ldapGroup = Group.findByName(context, dspaceGroupName);
                    if (ldapGroup != null) {
                        ldapGroup.addMember(context.getCurrentUser());
                        ldapGroup.update();
                        context.commit();
                    } else {
                        // The group does not exist
                        log.warn(LogManager.getHeader(context, "ldap_assignGroupsBasedOnLdapDn",
                                "Group defined in authentication-ldap.login.groupmap." + i
                                        + " does not exist :: " + dspaceGroupName));
                    }/*from w  ww.  j ava 2s . c  om*/
                } catch (AuthorizeException ae) {
                    log.debug(LogManager.getHeader(context,
                            "assignGroupsBasedOnLdapDn could not authorize addition to group",
                            dspaceGroupName));
                } catch (SQLException e) {
                    log.debug(LogManager.getHeader(context, "assignGroupsBasedOnLdapDn could not find group",
                            dspaceGroupName));
                }
            }

            groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + ++i);
        }
    }
}

From source file:org.ebayopensource.turmeric.eclipse.buildsystem.eclipse.BuildResourceDeltaVisitor.java

/**
 * Visits the code and if there are some changes in delta which we are
 * interested in, then it will set the build required to true and
 * immediately return./*  w ww . j a  va 2  s.  c  o  m*/
 * 
 * {@inheritDoc}
 * 
 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
 */
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
    // we dont want to go inside the output location.
    // This is JDTs business
    if (StringUtils.containsIgnoreCase(delta.getFullPath().toString(),
            javaProject.getOutputLocation().toString())) {
        return false;
    }
    // this is the only place where SOA Algorithm gives green signal for a
    // build
    // use default string here
    if (criteriaList.size() == 0) {
        if (StringUtils.containsIgnoreCase(delta.getFullPath().toString(), DEFAULT_CRITERIA)) {
            setBuildRequired(true);
            return false;
        }
    } else {// use the provided string here
        for (String criteria : criteriaList) {
            if (StringUtils.containsIgnoreCase(delta.getFullPath().toString(), criteria)) {
                setBuildRequired(true);
                return false;
            }
        }
    }
    return true;
}

From source file:org.ebayopensource.turmeric.eclipse.template.wsdl.util.ServiceTemplateUtil.java

/**
 * Adds a binding to the definition model being used. Here we have both SOAP
 * and HTTP bindings generation logic embedded. First we parse all the
 * bindings to see if we have an existing binding. If we don't have one the
 * we will add it. Note there is no hard coding for HTTP or SOAP here, but
 * is there in the UI and we just consult the WTP model before adding it.
 *
 * @param definition the definition//from w  w  w.  ja  v  a2s  . c o  m
 * @param bindings the bindings
 * @return the binding
 */
public static Binding addBinding(Definition definition, Set<TemplateBinding> bindings) {
    Binding binding = null;

    if (definition.getBindings() != null) {
        Iterator iterator = definition.getBindings().values().iterator();
        while (iterator.hasNext()) {
            Object objBinding = iterator.next();
            if (objBinding != null && objBinding instanceof Binding) {
                binding = (Binding) objBinding;
                BindingGenerator bindingGenerator = new BindingGenerator(definition, binding);
                for (TemplateBinding templBinding : bindings) {
                    // This is bad we are identifying the type
                    // of binding (ie if it is http or soap)
                    // by the name
                    if (StringUtils.containsIgnoreCase(binding.getQName().getLocalPart(),
                            templBinding.name())) {
                        if (bindingGenerator.getContentGenerator() == null) {
                            bindingGenerator.setOverwrite(true);
                            bindingGenerator.setContentGenerator(ContentGeneratorExtensionFactoryRegistry
                                    .getInstance().getGeneratorClassFromName(templBinding.name()));

                        }
                        bindingGenerator.generateBinding();

                    }
                }

            }
        }
    }

    if (binding == null) {
        binding = WSDLFactory.eINSTANCE.createBinding();
        binding.setQName(
                new QName(definition.getTargetNamespace(), ServiceTemplateConstants.DEFAULT_BINDING_NAME));
        binding.setEnclosingDefinition(definition);
        definition.addBinding(binding);
        BindingGenerator bindingGenerator = new BindingGenerator(definition, binding);
        bindingGenerator.generateBinding();
    }
    return binding;
}

From source file:org.eclipse.gyrex.boot.internal.console.FindCmd.java

@Override
protected void doExecute() throws Exception {
    final Bundle[] bundles = BootActivator.getInstance().getContext().getBundles();
    for (final Bundle bundle : bundles) {
        // skip bundles that are installed or uninstalled
        if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) != 0) {
            continue;
        }/*ww w . j  a v a 2 s .c om*/

        // check filter
        final String symbolicName = bundle.getSymbolicName();
        if ((null != filter) && !StringUtils.containsIgnoreCase(symbolicName, filter)) {
            continue;
        }

        // find options file
        final URL optionsEntry = bundle.getEntry(".options");
        if (null == optionsEntry) {
            continue;
        }

        // print options file
        final InputStream stream = optionsEntry.openStream();
        try {
            final List<String> lines = IOUtils.readLines(stream);

            final StrBuilder string = new StrBuilder();
            final int padWidth = symbolicName.length() + 6;
            string.appendPadding(padWidth, '-').appendNewLine();
            string.append("   ").append(symbolicName).appendNewLine();
            string.appendPadding(padWidth, '-').appendNewLine();
            for (final String line : lines) {
                string.append("> ").appendln(line);
            }
            printf(string.toString());
        } finally {
            IOUtils.closeQuietly(stream);
        }
    }
}

From source file:org.eclipse.gyrex.cloud.internal.console.ListNodesCmd.java

static boolean matchesFilter(final String filter, final INodeDescriptor node) {
    return StringUtils.isBlank(filter) || StringUtils.containsIgnoreCase(node.getId(), filter)
            || StringUtils.containsIgnoreCase(node.getName(), filter)
            || StringUtils.containsIgnoreCase(node.getLocation(), filter);
}

From source file:org.eclipse.gyrex.cloud.internal.queue.console.ListQueuesCmd.java

@Override
protected void doExecute() throws Exception {
    final ZooKeeperQueueService queueService = getQueueService();

    // collect (and sort) all queues
    final Collection<String> queueIds = new TreeSet<String>(queueService.getQueues());

    // check for direct match
    if (IdHelper.isValidId(filter) && queueIds.contains(filter)) {
        printQueueDetails(filter);/*  w  w w  .j  a va2 s  .  c o m*/
        return;
    }

    for (final String queueId : queueIds) {
        if (StringUtils.isBlank(filter) || StringUtils.containsIgnoreCase(queueId, filter)) {
            final ZooKeeperQueue queue = queueService.getQueue(queueId, null);
            if (null != queue) {
                printf("%s (%d)", queueId, queue.size());
            }
        }
    }
}

From source file:org.eclipse.gyrex.jobs.internal.commands.BaseScheduleStoreCmd.java

@Override
protected void doExecute() throws Exception {
    final boolean all = StringUtils.equals(scheduleStorageKey, "*");
    if (all || isFilter) {
        // process all matching schedules
        final String[] schedules = ScheduleStore.getSchedules();
        for (final String schedule : schedules) {
            if (all || StringUtils.containsIgnoreCase(schedule, scheduleStorageKey)) {
                doExecute(schedule, ScheduleManagerImpl.getExternalId(schedule));
            }/* w  w  w  .j  av  a  2s .c  o m*/
        }
    } else {
        // just single one
        if (!IdHelper.isValidId(scheduleStorageKey)) {
            throw new IllegalArgumentException("invalid storage key");
        }
        doExecute(scheduleStorageKey, ScheduleManagerImpl.getExternalId(scheduleStorageKey));
    }
}