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:com.genscript.gsscm.epicorwebservice.service.ErpSalesOrderService.java

@Traced
public Integer createCustomer(CustomerDTO customerDTO, String customerNo, String company) {
    CustomerService customerService = new CustomerService();
    CustomerServiceSoap port = customerService.getCustomerServiceSoap();
    assertUserNameToken(port);/*from   w  w  w .j  a v  a  2 s  . c  o m*/

    System.out.println("Invoking getNewCustomer...");
    String _update_companyID = company;
    //return createCustByCompany(customerDTO, customerNo, port,
    //         _update_companyID);
    Customer cust;
    Address shipToAddr = addressDao.getDefaultShipTOAddress(Integer.parseInt(customerNo));

    boolean _getByCustID_withShipTo = false;
    com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType _getByCustID_callContextIn = null;
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _getByCustID_getByCustIDResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _getByCustID_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
    try {
        port.getByCustID(_update_companyID, customerNo, _getByCustID_withShipTo, _getByCustID_callContextIn,
                _getByCustID_getByCustIDResult, _getByCustID_callContextOut);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (_getByCustID_getByCustIDResult.value == null) {
        com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType _getNewCustomer_ds = null;
        com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType _getNewCustomer_callContextIn = null;
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _getNewCustomer_getNewCustomerResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _getNewCustomer_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
        port.getNewCustomer(_update_companyID, _getNewCustomer_ds, _getNewCustomer_callContextIn,
                _getNewCustomer_getNewCustomerResult, _getNewCustomer_callContextOut);

        System.out.println("Invoking update...");
        Customer customer = (Customer) _getNewCustomer_getNewCustomerResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
        customer.setCompany(_update_companyID);
        customer.setName(AddressUtil.getFullName(customerDTO.getFirstName(), customerDTO.getMidName(),
                customerDTO.getLastName()));
        customer.setCustID(customerNo);
        customer.setAddress1(StringUtil.subStringByLength(shipToAddr.getAddrLine1(), 50));
        customer.setAddress2(StringUtil.subStringByLength(shipToAddr.getAddrLine2(), 50));
        customer.setAddress3(StringUtil.subStringByLength(shipToAddr.getAddrLine3(), 50));
        customer.setCity(shipToAddr.getCity());
        customer.setState(shipToAddr.getState());
        customer.setZip(shipToAddr.getZipCode());
        customer.setCountry(shipToAddr.getCountry());
        customer.setTerritoryID("Default");
        customer.setTermsCode(customerDTO.getPrefPaymentTerm() + "");
        customer.setCustomerType("CUS");
        //customer.setShipViaCode("9999");
        customer.setCreditHold(false);
        customer.setAllowOTS(true);
        customer.setShortChar01(customerDTO.getBusEmail());
        Organization organization = customerDTO.getOrganization();
        if (organization != null) {
            String orgName = organization.getName();
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "Norvartis")) {
                customer.setTermsCode("3");
            }
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "IRBM Science Park")) {
                customer.setTermsCode("5");
            }

        }
        boolean _update_continueProcessingOnError = false;

        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _update_updateResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
        javax.xml.ws.Holder<java.lang.Boolean> _update_errorsOccurred = new javax.xml.ws.Holder<java.lang.Boolean>();
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _update_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
        port.update(_update_companyID, _getNewCustomer_getNewCustomerResult.value,
                _update_continueProcessingOnError, _getNewCustomer_callContextOut.value, _update_updateResult,
                _update_errorsOccurred, _update_callContextOut);
        cust = (Customer) _update_updateResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
    } else {
        System.out.println("Invoking update...");
        Customer customer = (Customer) _getByCustID_getByCustIDResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
        customer.setCompany(_update_companyID);
        customer.setName(AddressUtil.getFullName(customerDTO.getFirstName(), customerDTO.getMidName(),
                customerDTO.getLastName()));
        customer.setCustID(customerNo);
        customer.setAddress1(StringUtil.subStringByLength(shipToAddr.getAddrLine1(), 50));
        customer.setAddress2(StringUtil.subStringByLength(shipToAddr.getAddrLine2(), 50));
        customer.setAddress3(StringUtil.subStringByLength(shipToAddr.getAddrLine3(), 50));
        customer.setCity(shipToAddr.getCity());
        customer.setState(shipToAddr.getState());
        customer.setZip(customerDTO.getZipCode());
        customer.setCountry(shipToAddr.getCountry());
        customer.setTerritoryID("Default");
        customer.setTermsCode(customerDTO.getPrefPaymentTerm() + "");
        customer.setCustomerType("CUS");
        //customer.setShipViaCode("9999");
        customer.setCreditHold(false);
        customer.setAllowOTS(true);
        customer.setShortChar01(customerDTO.getBusEmail());
        Organization organization = customerDTO.getOrganization();
        if (organization != null) {
            String orgName = organization.getName();
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "Norvartis")) {
                customer.setTermsCode("3");
            }
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "IRBM Science Park")) {
                customer.setTermsCode("5");
            }
        }
        boolean _update_continueProcessingOnError = false;

        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _update_updateResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
        javax.xml.ws.Holder<java.lang.Boolean> _update_errorsOccurred = new javax.xml.ws.Holder<java.lang.Boolean>();
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _update_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
        port.update(_update_companyID, _getByCustID_getByCustIDResult.value, _update_continueProcessingOnError,
                _getByCustID_callContextOut.value, _update_updateResult, _update_errorsOccurred,
                _update_callContextOut);
        cust = (Customer) _update_updateResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
    }
    return cust.getCustNum();

}

From source file:gov.nih.nci.cabig.caaers.rules.business.service.CaaersRulesEngineService.java

private CtcTerm findTerm(List<CtcTerm> terms, String categoryName) {
    if (terms == null || terms.isEmpty())
        return null;
    if (StringUtils.isEmpty(categoryName))
        return terms.get(0);
    if (terms.size() == 1)
        return terms.get(0);
    String c = StringUtils.replaceOnce(categoryName, "...", "");
    for (CtcTerm term : terms) {
        if (StringUtils.containsIgnoreCase(term.getCategory().getName(), c))
            return term;
    }//  w  w w.j a  v a 2 s .  c o m
    return null;
}

From source file:com.genscript.gsscm.epicorwebservice.service.ErpSalesOrderService.java

@Traced
private Integer createCustByCompany(CustomerDTO customerDTO, String customerNo, CustomerServiceSoap port,
        String _update_companyID) {
    Customer cust;// w  ww.  j a v a 2 s.  c  o  m
    Address shipToAddr = addressDao.getDefaultShipTOAddress(Integer.parseInt(customerNo));

    boolean _getByCustID_withShipTo = false;
    com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType _getByCustID_callContextIn = null;
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _getByCustID_getByCustIDResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _getByCustID_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
    try {
        port.getByCustID(_update_companyID, customerNo, _getByCustID_withShipTo, _getByCustID_callContextIn,
                _getByCustID_getByCustIDResult, _getByCustID_callContextOut);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (_getByCustID_getByCustIDResult.value == null) {
        com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType _getNewCustomer_ds = null;
        com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType _getNewCustomer_callContextIn = null;
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _getNewCustomer_getNewCustomerResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _getNewCustomer_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
        port.getNewCustomer(_update_companyID, _getNewCustomer_ds, _getNewCustomer_callContextIn,
                _getNewCustomer_getNewCustomerResult, _getNewCustomer_callContextOut);

        System.out.println("Invoking update...");
        Customer customer = (Customer) _getNewCustomer_getNewCustomerResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
        customer.setCompany(_update_companyID);
        customer.setName(AddressUtil.getFullName(customerDTO.getFirstName(), customerDTO.getMidName(),
                customerDTO.getLastName()));
        customer.setCustID(customerNo);
        customer.setAddress1(StringUtil.subStringByLength(shipToAddr.getAddrLine1(), 50));
        customer.setAddress2(StringUtil.subStringByLength(shipToAddr.getAddrLine2(), 50));
        customer.setAddress3(StringUtil.subStringByLength(shipToAddr.getAddrLine3(), 50));
        customer.setCity(shipToAddr.getCity());
        customer.setState(shipToAddr.getState());
        customer.setZip(shipToAddr.getZipCode());
        customer.setCountry(shipToAddr.getCountry());
        customer.setTerritoryID("Default");
        customer.setTermsCode(customerDTO.getPrefPaymentTerm() + "");
        customer.setCustomerType("CUS");
        //customer.setShipViaCode("9999");
        customer.setCreditHold(false);
        customer.setAllowOTS(true);
        customer.setShortChar01(customerDTO.getBusEmail());
        Organization organization = customerDTO.getOrganization();
        if (organization != null) {
            String orgName = organization.getName();
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "Norvartis")) {
                customer.setTermsCode("3");
            }
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "IRBM Science Park")) {
                customer.setTermsCode("5");
            }
        }
        boolean _update_continueProcessingOnError = false;

        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _update_updateResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
        javax.xml.ws.Holder<java.lang.Boolean> _update_errorsOccurred = new javax.xml.ws.Holder<java.lang.Boolean>();
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _update_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
        port.update(_update_companyID, _getNewCustomer_getNewCustomerResult.value,
                _update_continueProcessingOnError, _getNewCustomer_callContextOut.value, _update_updateResult,
                _update_errorsOccurred, _update_callContextOut);
        cust = (Customer) _update_updateResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
    } else {
        System.out.println("Invoking update...");
        Customer customer = (Customer) _getByCustID_getByCustIDResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
        customer.setCompany(_update_companyID);
        customer.setName(AddressUtil.getFullName(customerDTO.getFirstName(), customerDTO.getMidName(),
                customerDTO.getLastName()));
        customer.setCustID(customerNo);
        customer.setAddress1(StringUtil.subStringByLength(shipToAddr.getAddrLine1(), 50));
        customer.setAddress2(StringUtil.subStringByLength(shipToAddr.getAddrLine2(), 50));
        customer.setAddress3(StringUtil.subStringByLength(shipToAddr.getAddrLine3(), 50));
        customer.setCity(shipToAddr.getCity());
        customer.setState(shipToAddr.getState());
        customer.setZip(customerDTO.getZipCode());
        customer.setCountry(shipToAddr.getCountry());
        customer.setTerritoryID("Default");
        customer.setTermsCode(customerDTO.getPrefPaymentTerm() + "");
        customer.setCustomerType("CUS");
        //customer.setShipViaCode("9999");
        customer.setCreditHold(false);
        customer.setAllowOTS(true);
        customer.setShortChar01(customerDTO.getBusEmail());
        Organization organization = customerDTO.getOrganization();
        if (organization != null) {
            String orgName = organization.getName();
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "Norvartis")) {
                customer.setTermsCode("3");
            }
            if (orgName != null && StringUtils.containsIgnoreCase(orgName, "IRBM Science Park")) {
                customer.setTermsCode("5");
            }
        }
        boolean _update_continueProcessingOnError = false;

        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType> _update_updateResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CustomerDataSetType>();
        javax.xml.ws.Holder<java.lang.Boolean> _update_errorsOccurred = new javax.xml.ws.Holder<java.lang.Boolean>();
        javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType> _update_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.customer.CallContextDataSetType>();
        port.update(_update_companyID, _getByCustID_getByCustIDResult.value, _update_continueProcessingOnError,
                _getByCustID_callContextOut.value, _update_updateResult, _update_errorsOccurred,
                _update_callContextOut);
        cust = (Customer) _update_updateResult.value.getCustomerDataSet()
                .getCustomerOrCustomerAttchOrCustomCrdPool().get(0);
    }
    return cust.getCustNum();
}

From source file:de.sub.goobi.forms.ProzesskopieForm.java

/**
 * Generate title.//from ww w  . j a va2  s .c o  m
 *
 * @param genericFields
 *            Map of Strings
 * @return String
 */
public String generateTitle(Map<String, String> genericFields) throws IOException {
    String currentAuthors = "";
    String currentTitle = "";
    int counter = 0;
    for (AdditionalField field : this.additionalFields) {
        if (field.getAutogenerated() && field.getValue().isEmpty()) {
            field.setValue(String.valueOf(System.currentTimeMillis() + counter));
            counter++;
        }
        if (field.getMetadata() != null && field.getMetadata().equals("TitleDocMain")
                && currentTitle.length() == 0) {
            currentTitle = field.getValue();
        } else if (field.getMetadata() != null && field.getMetadata().equals("ListOfCreators")
                && currentAuthors.length() == 0) {
            currentAuthors = field.getValue();
        }

    }
    StringBuilder newTitle = new StringBuilder();
    String titeldefinition = "";
    ConfigProjects cp = new ConfigProjects(this.prozessVorlage.getProject().getTitle());

    int count = cp.getParamList("createNewProcess.itemlist.processtitle").size();
    for (int i = 0; i < count; i++) {
        String titel = cp.getParamString("createNewProcess.itemlist.processtitle(" + i + ")");
        String isdoctype = cp.getParamString("createNewProcess.itemlist.processtitle(" + i + ")[@isdoctype]");
        String isnotdoctype = cp
                .getParamString("createNewProcess.itemlist.processtitle(" + i + ")[@isnotdoctype]");

        if (titel == null) {
            titel = "";
        }
        if (isdoctype == null) {
            isdoctype = "";
        }
        if (isnotdoctype == null) {
            isnotdoctype = "";
        }

        /* wenn nix angegeben wurde, dann anzeigen */
        if (isdoctype.equals("") && isnotdoctype.equals("")) {
            titeldefinition = titel;
            break;
        }

        /* wenn beides angegeben wurde */
        if (!isdoctype.equals("") && !isnotdoctype.equals("")
                && StringUtils.containsIgnoreCase(isdoctype, this.docType)
                && !StringUtils.containsIgnoreCase(isnotdoctype, this.docType)) {
            titeldefinition = titel;
            break;
        }

        /* wenn nur pflicht angegeben wurde */
        if (isnotdoctype.equals("") && StringUtils.containsIgnoreCase(isdoctype, this.docType)) {
            titeldefinition = titel;
            break;
        }
        /* wenn nur "darf nicht" angegeben wurde */
        if (isdoctype.equals("") && !StringUtils.containsIgnoreCase(isnotdoctype, this.docType)) {
            titeldefinition = titel;
            break;
        }
    }

    StringTokenizer tokenizer = new StringTokenizer(titeldefinition, "+");
    /* jetzt den Bandtitel parsen */
    while (tokenizer.hasMoreTokens()) {
        String myString = tokenizer.nextToken();
        /*
         * wenn der String mit ' anfngt und mit ' endet, dann den Inhalt so
         * bernehmen
         */
        if (myString.startsWith("'") && myString.endsWith("'")) {
            newTitle.append(myString.substring(1, myString.length() - 1));
        } else if (myString.startsWith("#")) {
            /*
             * resolve strings beginning with # from generic fields
             */
            if (genericFields != null) {
                String genericValue = genericFields.get(myString);
                if (genericValue != null) {
                    newTitle.append(genericValue);
                }
            }
        } else {
            /* andernfalls den string als Feldnamen auswerten */
            for (AdditionalField additionalField : this.additionalFields) {
                /*
                 * wenn es das ATS oder TSL-Feld ist, dann den berechneten
                 * atstsl einsetzen, sofern noch nicht vorhanden
                 */
                if ((additionalField.getTitle().equals("ATS") || additionalField.getTitle().equals("TSL"))
                        && additionalField.getShowDependingOnDoctype()
                        && (additionalField.getValue() == null || additionalField.getValue().equals(""))) {
                    if (atstsl == null || atstsl.length() == 0) {
                        atstsl = createAtstsl(currentTitle, currentAuthors);
                    }
                    additionalField.setValue(this.atstsl);
                }

                /* den Inhalt zum Titel hinzufgen */
                if (additionalField.getTitle().equals(myString) && additionalField.getShowDependingOnDoctype()
                        && additionalField.getValue() != null) {
                    newTitle.append(
                            calculateProcessTitleCheck(additionalField.getTitle(), additionalField.getValue()));
                }
            }
        }
    }

    if (newTitle.toString().endsWith("_")) {
        newTitle.setLength(newTitle.length() - 1);
    }
    // remove non-ascii characters for the sake of TIFF header limits
    String filteredTitle = newTitle.toString().replaceAll("[^\\p{ASCII}]", "");
    prozessKopie.setTitle(filteredTitle);
    calculateTiffHeader();
    return filteredTitle;
}

From source file:com.portfolioeffect.quant.client.portfolio.Portfolio.java

public MethodResult findSymbols(String searchStr, int numResults) throws IOException {

    ArrayList<String> id = new ArrayList<String>();
    ArrayList<String> description = new ArrayList<String>();
    ArrayList<String> exchange = new ArrayList<String>();

    MethodResult allSymbols = getAllSymbolsList();
    String[] idStrings = allSymbols.getStringArray("id");
    String[] descriptionString = allSymbols.getStringArray("description");
    String[] exchangeString = allSymbols.getStringArray("exchange");

    for (int i = 0; i < idStrings.length; i++) {
        if (StringUtils.containsIgnoreCase(idStrings[i], searchStr)
                || StringUtils.containsIgnoreCase(descriptionString[i], searchStr)) {
            id.add(idStrings[i]);//from  w ww . j a v  a 2s  .  c  o  m
            description.add(descriptionString[i]);
            exchange.add(exchangeString[i]);
        }
        if (id.size() >= numResults) {
            break;
        }
    }

    MethodResult result = new MethodResult();

    ArrayCache idCache = new ArrayCache(id.toArray(new String[0]));
    result.setData("id", idCache);

    ArrayCache descriptionCache = new ArrayCache(description.toArray(new String[0]));
    result.setData("description", descriptionCache);

    ArrayCache exchangeCache = new ArrayCache(exchange.toArray(new String[0]));
    result.setData("exchange", exchangeCache);

    return result;
}

From source file:edu.ku.brc.specify.dbsupport.SpecifySchemaUpdateService.java

/**
 * @param conn/*from  w w  w. j a v  a 2 s  .  c o  m*/
 * @return
 */
public static boolean updateDNAAttachments(final Connection conn) {
    boolean isInnoDB = true;
    Object[] createRow = BasicSQLUtils.queryForRow("SHOW CREATE TABLE collectionobject");
    if (createRow != null && createRow.length > 1) {
        isInnoDB = StringUtils.containsIgnoreCase(createRow[1].toString(), "InnoDB");
    }

    String dbType = isInnoDB ? "InnoDB" : "MyISAM";
    String dnaSeqRunAttSQL = String.format(
            "CREATE TABLE `dnasequencerunattachment` ( `DnaSequencingRunAttachmentId` int(11) NOT NULL AUTO_INCREMENT, `TimestampCreated` datetime NOT NULL, `TimestampModified` datetime DEFAULT NULL, `Version` int(11) DEFAULT NULL, "
                    + "`Ordinal` int(11) DEFAULT NULL, `Remarks` text, `ModifiedByAgentID` int(11) DEFAULT NULL, `AttachmentID` int(11) NOT NULL, `CreatedByAgentID` int(11) DEFAULT NULL, `DnaSequencingRunID` int(11) NOT NULL, "
                    + "PRIMARY KEY (`DnaSequencingRunAttachmentId`), KEY `FKD0DAEB167699B003` (`CreatedByAgentID`), KEY `FKD0DAEB1678F036AA` (`DnaSequencingRunID`), KEY `FKD0DAEB16C7E55084` (`AttachmentID`), KEY `FKD0DAEB165327F942` (`ModifiedByAgentID`), "
                    + "CONSTRAINT `FKD0DAEB165327F942` FOREIGN KEY (`ModifiedByAgentID`) REFERENCES `agent` (`AgentID`), CONSTRAINT `FKD0DAEB167699B003` FOREIGN KEY (`CreatedByAgentID`) REFERENCES `agent` (`AgentID`), "
                    + "CONSTRAINT `FKD0DAEB1678F036AA` FOREIGN KEY (`DnaSequencingRunID`) REFERENCES `dnasequencingrun` (`DNASequencingRunID`), CONSTRAINT `FKD0DAEB16C7E55084` FOREIGN KEY (`AttachmentID`) REFERENCES `attachment` (`AttachmentID`) ) "
                    + "ENGINE=%s DEFAULT CHARSET=utf8;",
            dbType);

    String dnaSeqAttSQL = String.format(
            "CREATE TABLE `dnasequenceattachment` ( `DnaSequenceAttachmentId` int(11) NOT NULL AUTO_INCREMENT, `TimestampCreated` datetime NOT NULL, `TimestampModified` datetime DEFAULT NULL, `Version` int(11) DEFAULT NULL, "
                    + "`Ordinal` int(11) DEFAULT NULL, `Remarks` text, `AttachmentID` int(11) NOT NULL, `CreatedByAgentID` int(11) DEFAULT NULL, `DnaSequenceID` int(11) NOT NULL, `ModifiedByAgentID` int(11) DEFAULT NULL, PRIMARY KEY (`DnaSequenceAttachmentId`), "
                    + "KEY `FKFFC2E0FB265FB168` (`DnaSequenceID`), KEY `FKFFC2E0FB7699B003` (`CreatedByAgentID`), KEY `FKFFC2E0FBC7E55084` (`AttachmentID`), KEY `FKFFC2E0FB5327F942` (`ModifiedByAgentID`), "
                    + "CONSTRAINT `FKFFC2E0FB5327F942` FOREIGN KEY (`ModifiedByAgentID`) REFERENCES `agent` (`AgentID`), CONSTRAINT `FKFFC2E0FB265FB168` FOREIGN KEY (`DnaSequenceID`) REFERENCES `dnasequence` (`DnaSequenceID`), "
                    + "CONSTRAINT `FKFFC2E0FB7699B003` FOREIGN KEY (`CreatedByAgentID`) REFERENCES `agent` (`AgentID`), CONSTRAINT `FKFFC2E0FBC7E55084` FOREIGN KEY (`AttachmentID`) REFERENCES `attachment` (`AttachmentID`) ) "
                    + "ENGINE=%s DEFAULT CHARSET=utf8;",
            dbType);

    String insert = "INSERT INTO dnasequencerunattachment ( DnaSequencingRunAttachmentId, TimestampCreated, TimestampModified, Version, "
            + "Ordinal, Remarks, AttachmentID, CreatedByAgentID, DnaSequencingRunID, ModifiedByAgentID) "
            + "SELECT DnaSequencingRunAttachmentId, TimestampCreated, TimestampModified, Version, "
            + "Ordinal, Remarks, AttachmentID, CreatedByAgentID, DnaSequencingRunID, ModifiedByAgentID FROM dnasequenceattachment ORDER BY DnaSequencingRunAttachmentId ASC";

    DBMSUserMgr dbMgr = DBMSUserMgr.getInstance();
    dbMgr.setConnection(conn);

    String dnasequenceattachment = "dnasequenceattachment";

    boolean isDnaSeqInError = dbMgr.doesDBHaveTable(dnasequenceattachment)
            && dbMgr.doesFieldExistInTable(dnasequenceattachment, "DnaSequencingRunAttachmentId");

    int recCnt = BasicSQLUtils.getCountAsInt("SELECT COUNT(*) FROM dnasequenceattachment");
    log.debug("Number of dnasequenceattachment records: " + recCnt);

    boolean isDNASeqTableFixed = false;
    if (isDnaSeqInError) {
        if (recCnt == 0) {
            int rv = BasicSQLUtils.update(conn, "DROP TABLE dnasequenceattachment");
            log.debug("Dropped Old table dnasequenceattachment: " + rv);
            if (rv != 0) {
                log.info("Failed dropping dnasequenceattachment: " + rv);
                return false;
            }

            rv = BasicSQLUtils.update(conn, dnaSeqAttSQL);
            log.debug("Created New table dnasequenceattachment: " + rv);
            if (rv != 0) {
                log.info("Failed creating dnasequenceattachment: " + rv);
                return false;
            }
            isDNASeqTableFixed = true;

        } else {
            UIRegistry.showError(
                    "The is a problem with the DNASequenceAttachment table that can not be fixed automatically.\nPlease contact the Specify Help Desk.");
            return false;
        }
    }

    if (dbMgr.doesDBHaveTable("dnasequencerunattachment")) {
        log.error("dnasequencerunattachment already exists");
        return false;
    }

    int rv;

    rv = BasicSQLUtils.update(conn, dnaSeqRunAttSQL);
    log.debug("Created dnasequencerunattachment: " + rv);
    if (rv != 0) {
        log.info("Failed creating dnasequencerunattachment: " + rv);
        return false;
    }

    if (recCnt > 0) {
        rv = BasicSQLUtils.update(conn, insert);
        log.debug("Moved Records dnasequencerunattachment: " + rv);
        if (rv != 0) {
            log.info("Failed moving records dnasequencerunattachment: " + rv);
            return false;
        }
    }

    if (!isDNASeqTableFixed) {
        rv = BasicSQLUtils.update(conn, "DROP TABLE dnasequenceattachment");
        log.debug("Dropped Old table dnasequenceattachment: " + rv);
        if (rv != 0) {
            log.info("Failed dropping dnasequenceattachment: " + rv);
            return false;
        }

        rv = BasicSQLUtils.update(conn, dnaSeqAttSQL);
        log.debug("Created New table dnasequenceattachment: " + rv);
        if (rv != 0) {
            log.info("Failed creating dnasequenceattachment: " + rv);
            return false;
        }
    }

    return true;
}

From source file:net.triptech.metahive.service.EmailSenderService.java

/**
 * Send an email message using the configured Spring sender. On success
 * record the sent message in the datastore for reporting purposes
 *
 * @param email the email/*from   w ww  .  java2 s .  c om*/
 * @param attachments the attachments
 * @throws ServiceException the service exception
 */
public final void send(final SimpleMailMessage email, TreeMap<String, Object> attachments)
        throws ServiceException {

    // Check to see whether the required fields are set (to, from, message)
    if (email.getTo() == null) {
        throw new ServiceException("Error sending email: Recipient " + "address required");
    }
    if (StringUtils.isBlank(email.getFrom())) {
        throw new ServiceException("Error sending email: Email requires " + "a from address");
    }
    if (StringUtils.isBlank(email.getText())) {
        throw new ServiceException("Error sending email: No email " + "message specified");
    }
    if (mailSender == null) {
        throw new ServiceException("The JavaMail sender has not " + "been configured");
    }

    // Prepare the email message
    MimeMessage message = mailSender.createMimeMessage();
    MimeMessageHelper helper = null;
    boolean htmlMessage = false;
    if (StringUtils.containsIgnoreCase(email.getText(), "<html")) {
        htmlMessage = true;
        try {
            helper = new MimeMessageHelper(message, true, "UTF-8");
        } catch (MessagingException me) {
            throw new ServiceException("Error preparing email for sending: " + me.getMessage());
        }
    } else {
        helper = new MimeMessageHelper(message);
    }

    try {
        helper.setTo(email.getTo());
        helper.setFrom(email.getFrom());
        helper.setSubject(email.getSubject());

        if (email.getCc() != null) {
            helper.setCc(email.getCc());
        }
        if (email.getBcc() != null) {
            helper.setBcc(email.getBcc());
        }

        if (htmlMessage) {
            String plainText = email.getText();
            try {
                ConvertHtmlToText htmlToText = new ConvertHtmlToText();
                plainText = htmlToText.convert(email.getText());
            } catch (Exception e) {
                logger.error("Error converting HTML to plain text: " + e.getMessage());
            }
            helper.setText(plainText, email.getText());
        } else {
            helper.setText(email.getText());
        }

        if (email.getSentDate() != null) {
            helper.setSentDate(email.getSentDate());
        } else {
            helper.setSentDate(Calendar.getInstance().getTime());
        }

    } catch (MessagingException me) {
        throw new ServiceException("Error preparing email for sending: " + me.getMessage());
    }

    // Append any attachments (if an HTML email)
    if (htmlMessage && attachments != null) {
        for (String id : attachments.keySet()) {
            Object reference = attachments.get(id);

            if (reference instanceof File) {
                try {
                    FileSystemResource res = new FileSystemResource((File) reference);
                    helper.addInline(id, res);
                } catch (MessagingException me) {
                    logger.error("Error appending File attachment: " + me.getMessage());
                }
            }
            if (reference instanceof URL) {
                try {
                    UrlResource res = new UrlResource((URL) reference);
                    helper.addInline(id, res);
                } catch (MessagingException me) {
                    logger.error("Error appending URL attachment: " + me.getMessage());
                }
            }
        }
    }

    // Send the email message
    try {
        mailSender.send(message);
    } catch (MailException me) {
        logger.error("Error sending email: " + me.getMessage());
        throw new ServiceException("Error sending email: " + me.getMessage());
    }
}

From source file:net.ymate.module.oauth.base.OAuthClientUserBean.java

public boolean containsScope(Set<String> scopes) {
    boolean _flag = true;
    for (String _scope : scopes) {
        if (StringUtils.equalsIgnoreCase(IOAuth.Const.SCOPE_SNSAPI_BASE, _scope)) {
            continue;
        }//from   w ww.jav  a2 s .c o m
        if (!StringUtils.containsIgnoreCase(this.scope, _scope)) {
            _flag = false;
            break;
        }
    }
    return _flag;
}

From source file:net.ymate.module.oauth.impl.DefaultOAuthModuleCfg.java

public DefaultOAuthModuleCfg(YMP owner) {
    IConfigReader _moduleCfg = MapSafeConfigReader.bind(owner.getConfig().getModuleConfigs(IOAuth.MODULE_NAME));
    ////from w  ww.j a v  a  2 s . c  o  m
    __accessTokenExpireIn = _moduleCfg.getInt(ACCESS_TOKEN_EXPIRE_IN);
    if (__accessTokenExpireIn <= 0) {
        __accessTokenExpireIn = 7200;
    }
    //
    __refreshCountMax = _moduleCfg.getInt(REFRESH_COUNT_MAX);
    if (__refreshCountMax < 0) {
        __refreshCountMax = 0;
    }
    //
    __refreshTokenExpireIn = _moduleCfg.getInt(REFRESH_TOKEN_EXPIRE_IN);
    if (__refreshTokenExpireIn <= 0) {
        __refreshTokenExpireIn = 30;
    }
    //
    __authorizationCodeExpireIn = _moduleCfg.getInt(AUTHORIZATION_CODE_EXPIRE_IN);
    if (__authorizationCodeExpireIn <= 0) {
        __authorizationCodeExpireIn = 5;
    }
    //
    __cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfg.getString(CACHE_NAME_PREFIX));
    //
    __allowGrantTypes = new HashSet<GrantType>();
    String _grantTypeStr = _moduleCfg.getString(ALLOW_GRANT_TYPES, "none");
    if (!StringUtils.containsIgnoreCase(_grantTypeStr, "none")) {
        String[] _types = StringUtils.split(_grantTypeStr, "|");
        if (ArrayUtils.isNotEmpty(_types)) {
            for (String _item : _types) {
                try {
                    GrantType _type = GrantType.valueOf(StringUtils.upperCase(StringUtils.trimToEmpty(_item)));
                    __allowGrantTypes.add(_type);
                } catch (IllegalArgumentException ignored) {
                }
            }
        }
    }
    //
    if (!__allowGrantTypes.isEmpty()) {
        __tokenGenerator = _moduleCfg.getClassImpl(TOKEN_GENERATOR_CLASS, IOAuthTokenGenerator.class);
        if (__tokenGenerator == null) {
            __tokenGenerator = new DefaultTokenGenerator();
        }
        //
        __storageAdapter = _moduleCfg.getClassImpl(STORAGE_ADAPTER_CLASS, IOAuthStorageAdapter.class);
    }
    //
    __errorAdapter = _moduleCfg.getClassImpl(ERROR_ADAPTER_CLASS, IOAuthErrorAdapter.class);
    if (__errorAdapter == null) {
        __errorAdapter = new DefaultErrorAdapter();
    }
}

From source file:ninja.text.TextImpl.java

@Override
public boolean containsIgnoreCase(CharSequence part) {
    return StringUtils.containsIgnoreCase(data.toString(), part.toString());
}