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

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

Introduction

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

Prototype

public static boolean endsWithIgnoreCase(String str, String suffix) 

Source Link

Document

Case insensitive check if a String ends with a specified suffix.

Usage

From source file:net.navasoft.madcoin.backend.services.security.UserDataAccess.java

private RowMapper<User> defineMapper(String username) {
    if (!username.contains("@") && (!StringUtils.containsIgnoreCase(username, ".org")
            || !StringUtils.containsIgnoreCase(username, ".net")
            || !StringUtils.containsIgnoreCase(username, ".gov")
            || !StringUtils.endsWithIgnoreCase(username, ".com"))) {
        return nameMapper;
    } else {/*from w  w w  .j  a va  2  s .  c om*/
        return mailMapper;
    }
}

From source file:net.navasoft.madcoin.backend.services.security.ProviderDataAccess.java

/**
 * Define key./*ww  w .  j ava 2  s .co m*/
 * 
 * @param username
 *            the username
 * @return the string
 * @since 31/08/2014, 07:23:59 PM
 */
private String defineKey(String username) {
    if (!username.contains("@") && (!StringUtils.containsIgnoreCase(username, ".org")
            || !StringUtils.containsIgnoreCase(username, ".net")
            || !StringUtils.containsIgnoreCase(username, ".gov")
            || !StringUtils.endsWithIgnoreCase(username, ".com"))) {
        return AccessProperties.PROVIDER_NAME_QUERY.getConfigKey();
    } else {
        return AccessProperties.PROVIDER_MAIL_QUERY.getConfigKey();
    }
}

From source file:com.google.gdt.eclipse.designer.uibinder.editor.UiBinderPairResourceProvider.java

/**
 * @return the ui.xml {@link IFile} for given Java one.
 *//*from w w  w.  ja  v a 2s.c o  m*/
private IFile getUIFile(IFile javaFile) throws Exception {
    IProject project = javaFile.getProject();
    IJavaProject javaProject = JavaCore.create(project);
    // prepare form name
    String javaFormName = StringUtils.removeEnd(javaFile.getName(), ".java");
    // prepare package name
    String packageName;
    {
        IFolder folder = (IFolder) javaFile.getParent();
        IPackageFragment packageFragmentJava = (IPackageFragment) JavaCore.create(folder);
        packageName = packageFragmentJava.getElementName();
    }
    // try to find ui.xml file in package with same name
    for (IPackageFragmentRoot packageFragmentRoot : javaProject.getPackageFragmentRoots()) {
        IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(packageName);
        if (packageFragment.exists()) {
            for (Object object : packageFragment.getNonJavaResources()) {
                if (object instanceof IFile) {
                    IFile uiFile = (IFile) object;
                    String uiFileName = uiFile.getName();
                    if (StringUtils.endsWithIgnoreCase(uiFileName, ".ui.xml")) {
                        String uiFormName = StringUtils.removeEndIgnoreCase(uiFileName, ".ui.xml");
                        if (uiFormName.equals(javaFormName)) {
                            return uiFile;
                        }
                    }
                }
            }
        }
    }
    // no ui.xml file
    return null;
}

From source file:com.haulmont.cuba.core.sys.dbupdate.DbUpdaterImpl.java

@Override
protected boolean executeGroovyScript(final ScriptResource file) {
    Binding bind = new Binding();
    bind.setProperty("ds", getDataSource());
    bind.setProperty("log", LoggerFactory.getLogger(String.format("%s$%s", DbUpdaterEngine.class.getName(),
            StringUtils.removeEndIgnoreCase(file.getName(), ".groovy"))));
    if (!StringUtils.endsWithIgnoreCase(file.getName(), "." + UPGRADE_GROOVY_EXTENSION)) {
        bind.setProperty("postUpdate", new PostUpdateScripts() {
            @Override//  w  w  w  . j  ava 2s.com
            public void add(Closure closure) {
                postUpdateScripts.put(closure, file);

                postUpdate.add(closure);
            }

            @Override
            public List<Closure> getUpdates() {
                return postUpdate.getUpdates();
            }
        });
    }

    try {
        scripting.evaluateGroovy(file.getContent(), bind, ScriptExecutionPolicy.DO_NOT_USE_COMPILE_CACHE);
    } catch (Exception e) {
        throw new RuntimeException(ERROR + "Error executing Groovy script " + file.name + "\n" + e.getMessage(),
                e);
    }
    return !postUpdateScripts.containsValue(file);
}

From source file:com.tesora.dve.sql.util.ProxyConnectionResource.java

@Override
public ExceptionClassification classifyException(Throwable t) {
    if (t.getMessage() == null)
        return null;

    String msg = t.getMessage().trim();
    if (StringUtils.containsIgnoreCase(msg, "No such Table:")
            || StringUtils.containsIgnoreCase(msg, "No such Column:"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(msg, "No value found for required")
            && StringUtils.endsWithIgnoreCase(msg, "and no default specified"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(msg, "Unsupported statement kind for planning:")
            && StringUtils.endsWithIgnoreCase(msg, "RollbackTransactionStatement"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(msg, "Data Truncation:"))
        return ExceptionClassification.OUT_OF_RANGE;
    if (StringUtils.containsIgnoreCase(msg, "Unable to parse")
            || StringUtils.containsIgnoreCase(msg, "Unable to build plan")
            || StringUtils.containsIgnoreCase(msg, "Parsing FAILED:"))
        return ExceptionClassification.SYNTAX;
    if (StringUtils.containsIgnoreCase(msg, "Duplicate entry"))
        return ExceptionClassification.DUPLICATE;
    if (StringUtils.containsIgnoreCase(msg, "option not supported"))
        return ExceptionClassification.UNSUPPORTED_OPERATION;
    return null;//  w  ww  .  j a  va2 s  .c o m
}

From source file:net.navasoft.madcoin.backend.services.security.ProviderDataAccess.java

/**
 * Define mapper.//from  w w w  . jav a  2  s .com
 * 
 * @param username
 *            the username
 * @return the row mapper
 * @since 31/08/2014, 07:23:59 PM
 */
private RowMapper<User> defineMapper(String username) {
    if (!username.contains("@") && (!StringUtils.containsIgnoreCase(username, ".org")
            || !StringUtils.containsIgnoreCase(username, ".net")
            || !StringUtils.containsIgnoreCase(username, ".gov")
            || !StringUtils.endsWithIgnoreCase(username, ".com"))) {
        return nameMapper;
    } else {
        return mailMapper;
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.payments.SIBSPaymentsDA.java

public ActionForward uploadSIBSPaymentFiles(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws IOException {

    UploadBean bean = getRenderedObject("uploadBean");
    RenderUtils.invalidateViewState("uploadBean");

    if (bean == null) {
        return prepareUploadSIBSPaymentFiles(mapping, form, request, response);
    }/*from   ww w.j  a v a 2s.co  m*/

    if (StringUtils.endsWithIgnoreCase(bean.getFilename(), ZIP_FILE_EXTENSION)) {
        File zipFile = pt.utl.ist.fenix.tools.util.FileUtils.copyToTemporaryFile(bean.getInputStream());
        File unzipDir = null;
        try {
            unzipDir = pt.utl.ist.fenix.tools.util.FileUtils.unzipFile(zipFile);
            if (!unzipDir.isDirectory()) {
                addActionMessage("error", request, "error.manager.SIBS.zipException", bean.getFilename());
                return prepareUploadSIBSPaymentFiles(mapping, form, request, response);
            }
        } catch (Exception e) {
            addActionMessage("error", request, "error.manager.SIBS.zipException", getMessage(e));
            return prepareUploadSIBSPaymentFiles(mapping, form, request, response);
        } finally {
            zipFile.delete();
        }

        recursiveZipProcess(unzipDir, request);

    } else if (StringUtils.endsWithIgnoreCase(bean.getFilename(), PAYMENT_FILE_EXTENSION)) {
        InputStream inputStream = bean.getInputStream();
        File dir = Files.createTempDir();
        File tmp = new File(dir, bean.getFilename());
        tmp.deleteOnExit();

        try (OutputStream out = new FileOutputStream(tmp)) {
            ByteStreams.copy(inputStream, out);
        } finally {
            inputStream.close();
        }
        File file = tmp;
        ProcessResult result = new ProcessResult(request);
        result.addMessage("label.manager.SIBS.processingFile", file.getName());
        try {
            processFile(file, request);
        } catch (FileNotFoundException e) {
            addActionMessage("error", request, "error.manager.SIBS.zipException", getMessage(e));
        } catch (IOException e) {
            addActionMessage("error", request, "error.manager.SIBS.IOException", getMessage(e));
        } catch (Exception e) {
            addActionMessage("error", request, "error.manager.SIBS.fileException", getMessage(e));
        } finally {
            file.delete();
        }
    } else {
        addActionMessage("error", request, "error.manager.SIBS.notSupportedExtension", bean.getFilename());
    }
    return prepareUploadSIBSPaymentFiles(mapping, form, request, response);
}

From source file:com.tesora.dve.sql.util.DBHelperConnectionResource.java

@Override
public ExceptionClassification classifyException(Throwable t) {
    if (t.getMessage() == null)
        return null;
    String m = t.getMessage().trim();
    if (StringUtils.containsIgnoreCase(m, "Table") && StringUtils.endsWithIgnoreCase(m, "doesn't exist"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Unknown table")
            || StringUtils.containsIgnoreCase(m, "Unknown column"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Every derived table must have its own alias"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Field")
            && StringUtils.endsWithIgnoreCase(m, "doesn't have a default value"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "SAVEPOINT") && StringUtils.endsWithIgnoreCase(m, "does not exist"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Data Truncation:"))
        return ExceptionClassification.OUT_OF_RANGE;
    if (StringUtils.containsIgnoreCase(m, "You have an error in your SQL syntax"))
        return ExceptionClassification.SYNTAX;
    if (StringUtils.containsIgnoreCase(m, "Duplicate entry"))
        return ExceptionClassification.DUPLICATE;
    if (StringUtils.containsIgnoreCase(m, "option not supported"))
        return ExceptionClassification.UNSUPPORTED_OPERATION;
    if (StringUtils.startsWithIgnoreCase(m, "File") && StringUtils.containsIgnoreCase(m, "not found"))
        return ExceptionClassification.FILE_NOT_FOUND;
    if (StringUtils.startsWithIgnoreCase(m, "Table") && StringUtils.endsWithIgnoreCase(m, "already exists"))
        return ExceptionClassification.DUPLICATE;
    return null;/*from w  w w.ja  v  a2  s .  co  m*/
}

From source file:hydrograph.ui.perspective.dialog.JdkPathDialog.java

private String getTextBoxValue() {
    String textValue = text.getText();
    if (!StringUtils.endsWithIgnoreCase(textValue, File.separator + "bin")) {
        textValue = textValue + File.separator + "bin";
    }/*from  w  ww. j  a va 2 s  .c  om*/
    return textValue;
}

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

private static boolean checkEndsWith(String finalParamPath, String[] fileExtensions) {
    for (String extension : fileExtensions) {
        if (StringUtils.endsWithIgnoreCase(finalParamPath, extension)) {
            return true;
        }/*from w  w  w. j  a  v a  2 s .  c o m*/
    }
    return false;
}