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

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

Introduction

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

Prototype

public static String substringAfter(String str, String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:org.beangle.ems.avatar.service.FileSystemAvatarBase.java

public Page<String> getAvatarNames(PageLimit limit) {
    if (null == avatarDir) {
        logger.error("avatar dir property not config properly");
        return Pages.emptyPage();
    }//from  w  ww.  ja v a  2 s . c o  m
    File file = new File(avatarDir);
    if (!file.exists()) {
        return Pages.emptyPage();
    }
    String[] names = file.list();
    List<String> fileNames = CollectUtils.newArrayList();
    for (int i = 0; i < names.length; i++) {
        String name = StringUtils.substringBefore(names[i], ".");
        String ext = StringUtils.substringAfter(names[i], ".");
        if (StringUtils.isNotBlank(name) && containType(ext)) {
            fileNames.add(name);
        }
    }
    Collections.sort(fileNames);
    return new PagedList<String>(fileNames, limit);
}

From source file:org.beangle.ems.security.restrict.service.RestrictionServiceImpl.java

private List<?> getFieldValues(RestrictField field) {
    if (null == field.getSource())
        return Collections.emptyList();
    String source = field.getSource();
    String prefix = StringUtils.substringBefore(source, ":");
    source = StringUtils.substringAfter(source, ":");
    DataProvider provider = providers.get(prefix);
    if (null != provider) {
        return provider.getData(field, source);
    } else {// w ww  .ja  va2s .  c om
        throw new RuntimeException("not support data provider:" + prefix);
    }
}

From source file:org.beangle.emsapp.avatar.action.BoardAction.java

public String upload() throws Exception {
    File[] files = (File[]) getAll("avatar");
    String userName = get("user.name");
    if (files != null && files.length > 0) {
        String type = StringUtils.substringAfter(get("avatarFileName"), ".");
        boolean passed = avatarBase.containType(type);
        if (passed) {
            avatarBase.updateAvatar(userName, files[0], type);
        } else {/*  w  ww .  j a  v a  2 s .com*/
            addActionError("??");
            return forward("info");
        }
    }
    return redirect(new Action(UserAction.class, "info", "&user.name=" + userName), "info.save.success");
}

From source file:org.beangle.emsapp.avatar.action.MyUploadAction.java

public String upload() throws Exception {
    File[] files = (File[]) getAll("avatar");
    if (files.length > 0) {
        String type = StringUtils.substringAfter(get("avatarFileName"), ".");
        boolean passed = avatarBase.containType(type);
        if (passed) {
            avatarBase.updateAvatar(getUsername(), files[0], type);
        } else {//  ww  w.j av a 2s. c  o  m
            return forward("upload");
        }
    }
    return redirect(new Action(MyAction.class, "info"), "info.upload.success");
}

From source file:org.beangle.model.persist.hibernate.support.DefaultTableNameConfig.java

private void loadProperties(URL url) {
    try {/*from ww  w  .j a va  2 s . co  m*/
        logger.debug("loading {}", url);
        InputStream is = url.openStream();
        Properties props = new Properties();
        if (null != is) {
            props.load(is);
        }
        for (Iterator<Object> iter = props.keySet().iterator(); iter.hasNext();) {
            String packageName = (String) iter.next();
            String schemaPrefix = props.getProperty(packageName).trim();

            String schema = null;
            String prefix = null;
            String abbreviationStr = null;
            int commaIndex = schemaPrefix.indexOf(',');
            if (commaIndex < 0 || (commaIndex + 1 == schemaPrefix.length())) {
                schema = schemaPrefix;
            } else if (commaIndex == 0) {
                prefix = schemaPrefix.substring(1);
            } else {
                schema = StringUtils.substringBefore(schemaPrefix, ",");
                prefix = StringUtils.substringAfter(schemaPrefix, ",");
            }
            if (StringUtils.contains(prefix, ",")) {
                abbreviationStr = StringUtils.substringAfter(prefix, ",").toLowerCase();
                prefix = StringUtils.substringBefore(prefix, ",");
            }
            TableNamePattern pattern = (TableNamePattern) packagePatterns.get(packageName);
            if (null == pattern) {
                pattern = new TableNamePattern(packageName, schema, prefix);
                packagePatterns.put(packageName, pattern);
                patterns.add(pattern);
            } else {
                pattern.setSchema(schema);
                pattern.setPrefix(prefix);
            }
            if (null != abbreviationStr) {
                String[] pairs = StringUtils.split(abbreviationStr, ";");
                for (String pair : pairs) {
                    String longName = StringUtils.substringBefore(pair, "=");
                    String shortName = StringUtils.substringAfter(pair, "=");
                    pattern.abbreviations.put(longName, shortName);
                }
            }
        }
        is.close();
    } catch (IOException e) {
        logger.error("property load error", e);
    }
}

From source file:org.beangle.model.transfer.importer.MultiEntityImporter.java

public String processAttr(String attr) {
    return StringUtils.substringAfter(attr, ".");
}

From source file:org.beangle.notification.notifiers.mail.AbstractMailNotifier.java

public void deliver(T mailMsg) throws NotificationException {
    MimeMessage mimeMsg = mailSender.createMimeMessage();
    try {//  ww  w  .  ja v  a  2s .  c om
        if (null == mailMsg.getSendAt()) {
            mimeMsg.setSentDate(new Date());
        } else {
            mimeMsg.setSentDate(mailMsg.getSendAt());
        }
        MimeMessageHelper messageHelper = null;
        String encoding = StringUtils.substringAfter(mailMsg.getContentType(), "charset=");
        if (StringUtils.isEmpty(encoding)) {
            messageHelper = new MimeMessageHelper(mimeMsg);
        } else {
            messageHelper = new MimeMessageHelper(mimeMsg, encoding);
        }
        messageHelper.setText(buildText(mailMsg), StringUtils.contains(mailMsg.getContentType(), "html"));
        String subject = buildSubject(mailMsg);
        messageHelper.setSubject(subject);
        int recipients = addRecipient(mimeMsg, mailMsg);
        beforeSend(mailMsg, mimeMsg);
        if (recipients > 0) {
            mailSender.send(mimeMsg);
            if (logger.isDebugEnabled()) {
                logger.debug("mail sended from {} to {} with subject {}",
                        new Object[] { from, mailMsg.getRecipients(), subject });
            }
        } else {
            logger.warn("{} without any recipients ,sending aborted!", subject);
        }
    } catch (AddressException ex) {
        throw new NotificationException("Exception while sending message.", ex);
    } catch (MessagingException ex) {
        throw new NotificationException("Exception while sending message.", ex);
    }
    afterSend(mailMsg, mimeMsg);
}

From source file:org.beangle.notification.notifiers.mail.MailMessage.java

public String getEncoding() {
    return StringUtils.substringAfter(getContentType(), "charset=");
}

From source file:org.beangle.struts2.action.EntityDrivenAction.java

public String exportDataSelect() {
    String format = get("format");
    String fileName = get("fileName");
    String template = get("template");
    put("format", format);
    put("fileName", fileName);
    put("template", template);
    String properties = get("properties");
    if (StringUtils.isNotEmpty(properties)) {
        String[] props = StringUtils.split(properties, ",");
        List<String> keys = CollectUtils.newArrayList();
        Map<String, String> titles = CollectUtils.newHashMap();
        for (String prop : props) {
            String key = StringUtils.substringBefore(prop, ":");
            System.out.println(key);
            String value = getTextInternal(StringUtils.substringAfter(prop, ":"));
            keys.add(key);//from   w w  w. j a va 2 s .  co  m
            titles.put(key, value);
        }
        put("keys", keys);
        put("titles", titles);
    }
    return forward("/template/exportDataSelect");
}