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

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

Introduction

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

Prototype

public static String substringAfterLast(String str, String separator) 

Source Link

Document

Gets the substring after the last occurrence of a separator.

Usage

From source file:com.alibaba.otter.manager.biz.monitor.impl.AbstractRuleMonitor.java

protected boolean inPeriod(AlarmRule alarmRule) {
    String rule = alarmRule.getMatchValue();
    if (StringUtils.isEmpty(rule)) {
        log.info("rule is empty " + alarmRule);
        return false;
    }//from   w  w  w . ja  v a 2s.  c  o  m

    String periods = StringUtils.substringAfterLast(rule, "@");
    if (StringUtils.isEmpty(periods)) {
        // ?
        return isInPeriodWhenNoPeriod();
    }

    Calendar calendar = currentCalendar();
    periods = StringUtils.trim(periods);
    for (String period : StringUtils.split(periods, ",")) {
        String[] startAndEnd = StringUtils.split(period, "-");
        if (startAndEnd == null || startAndEnd.length != 2) {
            log.error("error period time format in rule : " + alarmRule);
            return isInPeriodWhenErrorFormat();
        }

        String start = startAndEnd[0];
        String end = startAndEnd[1];
        if (checkInPeriod(calendar, start, end)) {
            log.info("rule is in period : " + alarmRule);
            return true;
        }
    }

    log.info("rule is not in period : " + alarmRule);
    return false;
}

From source file:com.amalto.core.util.DigestHelper.java

/**
 * @param type A type of resource (see constants in {@link DigestHelper}).
 * @return The MDM internal class name//from w w  w.j  a v  a  2s  .co  m
 */
public String getTypeName(String type) {
    String name = null;
    if (TYPE_DATA_CLUSTER.equals(type)) {
        name = DataClusterPOJO.class.getName();
    } else if (TYPE_DATA_MODEL.equals(type)) {
        name = DataModelPOJO.class.getName();
    } else if (TYPE_VIEW.equals(type)) {
        name = ViewPOJO.class.getName();
    } else if (TYPE_ROLE.equals(type)) {
        name = RolePOJO.class.getName();
    } else if (TYPE_MENU.equals(type)) {
        name = MenuPOJO.class.getName();
    } else if (TYPE_STORED_PROCEDURE.equals(type)) {
        name = StoredProcedurePOJO.class.getName();
    } else if (TYPE_TRANSFORMER.equals(type)) {
        name = TransformerV2POJO.class.getName();
    } else if (TYPE_ROUTING_RULE.equals(type)) {
        name = RoutingRulePOJO.class.getName();
    } else if (TYPE_SERVICE_CONFIGURATION.equals(type)) {
        name = ConfigurationInfoPOJO.class.getName();
    } else if (TYPE_CUSTOM_FORM.equals(type)) {
        name = CustomFormPOJO.class.getName();
    } else if (TYPE_MATCH_RULE.equals(type)) {
        name = StorageAdminImpl.MATCH_RULE_POJO_CLASS; // Class is not in class path when running CE edition.
    } else {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Type '" + type + "' is not supported.");
        }
    }
    return name != null ? StringUtils.substringAfterLast(name, ".") : null; //$NON-NLS-1$
}

From source file:com.adobe.acs.commons.search.impl.NodeExistsPredicateEvaluator.java

@Override
@SuppressWarnings("squid:S3776")
public final boolean includes(final Predicate predicate, final Row row, final EvaluationContext context) {
    boolean or = predicate.getBool(OR);

    if (log.isDebugEnabled()) {
        if (or) {
            log.debug("NodeExistsPredicatorEvaluator evaluating as [ OR ]");
        } else {//from  ww w  .  j a va2 s  .co m
            log.debug("NodeExistsPredicatorEvaluator evaluating as [ AND ]");
        }
    }

    for (final Map.Entry<String, String> entry : predicate.getParameters().entrySet()) {
        boolean ruleIncludes = false;

        String operation = entry.getKey();
        if (StringUtils.contains(operation, "_")) {
            operation = StringUtils.substringAfterLast(entry.getKey(), "_");
        }

        try {
            if (EXISTS_REL_PATH.equals(operation)) {
                ruleIncludes = row.getNode().hasNode(entry.getValue());
            } else if (NOT_EXISTS_REL_PATH.equals(operation)) {
                ruleIncludes = !row.getNode().hasNode(entry.getValue());
            } else if (!OR.equals(operation)) {
                log.debug("Invalid operation [ {} ]", operation);
            }

            // Return quickly from the evaluation loop
            if (or && ruleIncludes) {
                // If OR condition; return true on the first condition match
                if (log.isDebugEnabled()) {
                    log.debug("Including [ {} ] based on [ {}  -> {} ] as part of [ OR ]", row.getPath(),
                            operation, entry.getValue());
                }
                return true;
            } else if (!or && !ruleIncludes) {
                // If AND condition; return true on the first condition failure
                if (log.isDebugEnabled()) {
                    log.debug("Excluding [ {} ] based on [ {}  -> {} ] as part of [ AND ]", row.getPath(),
                            operation, entry.getValue());
                }

                return false;
            }
        } catch (RepositoryException e) {
            log.error("Unable to check if Node [ {} : {} ] via the nodeExists QueryBuilder predicate",
                    new String[] { entry.getKey(), entry.getValue() }, e);
        }
    }

    if (or) {
        // For ORs, if a true condition was met in the loop, the method would have already returned true, so must be false.
        if (log.isDebugEnabled()) {
            try {
                log.debug("Excluding [ {} ] based on NOT matching conditions as part of [ OR ]", row.getPath());
            } catch (RepositoryException e) {
                log.error("Could not obtain path from for Result row in predicate evaluator", e);
            }
        }
        return false;
    } else {
        // If ANDs, if a false condition was met in the loop, the method would have already returned false, so must be true.
        if (log.isDebugEnabled()) {
            try {
                log.debug("Include [ {} ] based on ALL matching conditions as part of [ AND ]", row.getPath());
            } catch (RepositoryException e) {
                log.error("Could not obtain path from for Result row in predicate evaluator", e);
            }
        }
        return true;
    }
}

From source file:com.hangum.tadpole.engine.sql.util.sqlscripts.scripts.MySqlDDLScript.java

@Override
public String getProcedureScript(ProcedureFunctionDAO procedureDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
    Map srcList = (HashMap) client.queryForObject("getProcedureScript", procedureDAO.getName());
    String strSource = "" + srcList.get("Create Procedure");
    strSource = StringUtils.substringAfterLast(strSource, "PROCEDURE");

    return "CREATE PROCEDURE " + strSource;
}

From source file:info.magnolia.cms.core.Path.java

public static String getExtension(HttpServletRequest req) {
    return StringUtils.substringAfterLast(req.getRequestURI(), "."); //$NON-NLS-1$
}

From source file:com.cloud.storage.template.S3TemplateDownloader.java

public S3TemplateDownloader(S3TO s3TO, String downloadUrl, String installPath,
        DownloadCompleteCallback downloadCompleteCallback, long maxTemplateSizeInBytes, String username,
        String password, Proxy proxy, ResourceType resourceType) {
    this.downloadUrl = downloadUrl;
    this.s3TO = s3TO;
    this.resourceType = resourceType;
    this.maxTemplateSizeInByte = maxTemplateSizeInBytes;
    this.httpClient = HTTPUtils.getHTTPClient();
    this.downloadCompleteCallback = downloadCompleteCallback;

    // Create a GET method for the download url.
    this.getMethod = new GetMethod(downloadUrl);

    // Set the retry handler, default to retry 5 times.
    this.getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            HTTPUtils.getHttpMethodRetryHandler(5));

    // Follow redirects
    this.getMethod.setFollowRedirects(true);

    // Set file extension.
    this.fileExtension = StringUtils.substringAfterLast(StringUtils.substringAfterLast(downloadUrl, "/"), ".");

    // Calculate and set S3 Key.
    this.s3Key = join(asList(installPath, StringUtils.substringAfterLast(downloadUrl, "/")), S3Utils.SEPARATOR);

    // Set proxy if available.
    HTTPUtils.setProxy(proxy, this.httpClient);

    // Set credentials if available.
    HTTPUtils.setCredentials(username, password, this.httpClient);
}

From source file:edu.mayo.cts2.framework.plugin.service.bprdf.profile.codesystem.BioportalRdfCodeSystemReadService.java

/**
 * Gets the ontology id from uri./*  w w w  .j  a v a2 s . c  o  m*/
 *
 * @param uri the uri
 * @return the ontology id from uri
 */
private String getOntologyIdFromUri(String uri) {
    String acronym = StringUtils.substringAfterLast(uri, "/");

    return this.idService.getOntologyIdForAcronym(acronym);
}

From source file:com.adobe.ac.pmd.rules.core.AbstractFlexRule.java

/**
 * @param violatedLine/*from  ww  w. j a va2 s . com*/
 * @return
 */
boolean isViolationIgnored(final String violatedLine) {
    final boolean containsNoPmd = lineContainsNoPmd(violatedLine, MXML_COMMENT_TOKEN)
            || lineContainsNoPmd(violatedLine, AS3_COMMENT_TOKEN);

    if (!containsNoPmd) {
        return false;
    }
    final String name = getRuleName().replaceAll("Rule", "");
    final String ruleName = name.contains(".") ? StringUtils.substringAfterLast(name, ".") : name;
    final String strippedLine = computeStrippedLine(violatedLine);
    return strippedLineContainsNoPmdAndRuleName(MXML_COMMENT_TOKEN, ruleName, strippedLine)
            || strippedLineContainsNoPmdAndRuleName(AS3_COMMENT_TOKEN, ruleName, strippedLine);
}

From source file:com.sonicle.webtop.core.app.shiro.WTRealm.java

@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    if (token instanceof UsernamePasswordToken) {
        UsernamePasswordToken upt = (UsernamePasswordToken) token;

        String domainId = null;/*from   www  .  j  a  v a2 s  .  c o m*/
        if (token instanceof UsernamePasswordDomainToken) {
            domainId = ((UsernamePasswordDomainToken) token).getDomain();
        }
        //logger.debug("isRememberMe={}",upt.isRememberMe());

        String sprincipal = (String) upt.getPrincipal();
        String internetDomain = StringUtils.lowerCase(StringUtils.substringAfterLast(sprincipal, "@"));
        String username = StringUtils.substringBeforeLast(sprincipal, "@");
        logger.trace("doGetAuthenticationInfo [{}, {}, {}]", domainId, internetDomain, username);

        Principal principal = authenticateUser(domainId, internetDomain, username, upt.getPassword());

        // Update token with new values resulting from authentication
        if (token instanceof UsernamePasswordDomainToken) {
            ((UsernamePasswordDomainToken) token).setDomain(principal.getDomainId());
        }
        upt.setUsername(principal.getUserId());

        return new WTAuthenticationInfo(principal, upt.getPassword(), this.getName());

    } else {
        return null;
    }
}

From source file:info.magnolia.module.delta.PartialBootstrapTask.java

public PartialBootstrapTask(String name, String description, String resource, String itemPath,
        int importUUIDBehavior) {
    super(name, description);

    this.importUUIDBehavior = importUUIDBehavior;
    this.resource = resource;
    this.itemPath = StringUtils.chomp(itemPath, "/").replace(".", "..");
    this.itemName = StringUtils.substringAfterLast(itemPath, "/");
}