Example usage for org.apache.commons.lang ArrayUtils contains

List of usage examples for org.apache.commons.lang ArrayUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils contains.

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:com.adobe.acs.commons.workflow.process.impl.ParameterizedActivatePageProcess.java

@Override
protected ReplicationOptions prepareOptions(ReplicationOptions opts) {

    if (opts == null) {
        opts = new ReplicationOptions();
    }/*from  www  .j  a v a2  s .c o m*/
    opts.setFilter(new AgentFilter() {

        @Override
        public boolean isIncluded(Agent agent) {

            if (ArrayUtils.isEmpty(agentId.get())) {
                return false;
            }
            return ArrayUtils.contains(agentId.get(), agent.getId());
        }
    });
    return opts;
}

From source file:com.google.gdt.eclipse.designer.gxt.databinding.wizards.autobindings.GxtWidgetDescriptor.java

@Override
public boolean isDefault(Object property) {
    PropertyAdapter propertyAdapter = (PropertyAdapter) property;
    Class<?> propertyType = propertyAdapter.getType();
    if (propertyType != null) {
        return ArrayUtils.contains(m_propertyClasses, propertyType.getName());
    }//from w  ww  .j ava  2s.  c  o  m
    return false;
}

From source file:jp.co.opentone.bsol.linkbinder.subscriber.RedisSubscriber.java

@Override
public void onMessage(String channel, String message) {
    log.info("[{}] RECEIVED: {}, {}", new Object[] { getClass().getSimpleName(), channel, message });
    AbstractDomainEvent event = SubscriberUtil.parseJsonMessage(message, AbstractDomainEvent.class);
    subscribers.forEach(s -> {/* w w  w  .  j a v  a2s  . com*/
        String[] eventNames = s.getMyEvents();
        if (ArrayUtils.contains(eventNames, event.getEventName())) {
            s.onMessage(event.getEventName(), message);
        }
    });
}

From source file:ch.entwine.weblounge.bridge.oaipmh.harvester.LastHarvested.java

/**
 * Remove all URLs from the table that do not exist in <code>keepUrls</code>.
 *//*from w  w  w .  j  a  va 2s  .c om*/
public static void cleanup(PersistenceEnv penv, final String[] keepUrls) {
    penv.tx(new Function<EntityManager, Void>() {
        public Void apply(EntityManager em) {
            List<LastHarvested> lhs = em.createNamedQuery("findAll").getResultList();
            for (LastHarvested lh : lhs) {
                if (!ArrayUtils.contains(keepUrls, lh.getUrl())) {
                    em.remove(lh);
                }
            }
            return null;
        }
    });
}

From source file:com.adobe.acs.commons.util.visitors.ContentVisitor.java

@Override
protected void visit(Resource resource) {
    try {//from w  ww.  j a  v  a  2  s. c  om
        final String primaryType = resource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class);

        if (ArrayUtils.contains(contentTypes, primaryType)) {
            runnable.run(resource);
        }
    } catch (Exception e) {
        log.error("An error occurred while visiting resource [ {} ]", resource.getPath(), e);
    }
}

From source file:com.hyeb.back.log.LogInterceptor.java

@SuppressWarnings("unchecked")
@Override//ww  w .j  ava2s  . c om
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    List<LogConfig> logConfigs = logConfigService.getAll();
    if (logConfigs != null) {
        String path = request.getServletPath();
        for (LogConfig logConfig : logConfigs) {
            if (antPathMatcher.match(logConfig.getUrlPattern(), path)) {
                String username = sysUserService.getCurrentUsername();
                String operation = logConfig.getOperation();
                String operator = username;
                String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                String ip = request.getRemoteAddr();
                request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                StringBuffer parameter = new StringBuffer();
                Map<String, String[]> parameterMap = request.getParameterMap();
                if (parameterMap != null) {
                    for (Entry<String, String[]> entry : parameterMap.entrySet()) {
                        String parameterName = entry.getKey();
                        if (!ArrayUtils.contains(ignoreParameters, parameterName)) {
                            String[] parameterValues = entry.getValue();
                            if (parameterValues != null) {
                                for (String parameterValue : parameterValues) {
                                    parameter.append(parameterName + " = " + parameterValue + "\n");
                                }
                            }
                        }
                    }
                }
                Log log = new Log();
                log.setOperation(operation);
                log.setOperator(operator);
                log.setContent(content);
                log.setParameter(parameter.toString());
                log.setIp(ip);
                logService.save(log);
                break;
            }
        }
    }
}

From source file:gov.guilin.interceptor.LogInterceptor.java

@SuppressWarnings("unchecked")
@Override//from ww  w  . ja va 2  s.c o  m
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    List<LogConfig> logConfigs = logConfigService.getAll();
    if (logConfigs != null) {
        String path = request.getServletPath();
        for (LogConfig logConfig : logConfigs) {
            if (antPathMatcher.match(logConfig.getUrlPattern(), path)) {
                String username = adminService.getCurrentUsername();
                String operation = logConfig.getOperation();
                String operator = username;
                String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                String ip = request.getRemoteAddr();
                request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                StringBuffer parameter = new StringBuffer();
                Map<String, String[]> parameterMap = request.getParameterMap();
                if (parameterMap != null) {
                    for (Entry<String, String[]> entry : parameterMap.entrySet()) {
                        String parameterName = entry.getKey();
                        if (!ArrayUtils.contains(ignoreParameters, parameterName)) {
                            String[] parameterValues = entry.getValue();
                            if (parameterValues != null) {
                                for (String parameterValue : parameterValues) {
                                    parameter.append(parameterName + " = " + parameterValue + "\n");
                                }
                            }
                        }
                    }
                }
                Log log = new Log();
                log.setOperation(operation);
                log.setOperator(operator);
                log.setContent(content);
                log.setParameter(parameter.toString());
                log.setIp(ip);
                logService.save(log);
                break;
            }
        }
    }
}

From source file:eu.sofia.adk.common.xsd.JavaDatatype.java

/**
 * Determines if the datatype is a double datatype 
 * @param datatype a string representation of the datatype
 * @return <code>true</code> if the datatype is a double type
 *///from w w w  .j a  va  2 s .c om
private static boolean isDoubleDatatype(String datatype) {
    return ArrayUtils.contains(doubleDatatype, datatype);
}

From source file:com.sammyun.AuthenticationRealm.java

/**
 * ???/*from  w w  w .ja v a 2s .  c o  m*/
 * 
 * @param token 
 * @return ??
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token) {
    AuthenticationToken authenticationToken = (AuthenticationToken) token;
    String username = authenticationToken.getUsername();
    String password = new String(authenticationToken.getPassword());
    String captchaId = authenticationToken.getCaptchaId();
    String captcha = authenticationToken.getCaptcha();
    String ip = authenticationToken.getHost();
    if (!captchaService.isValid(CaptchaType.consoleLogin, captchaId, captcha)) {
        throw new UnsupportedTokenException();
    }
    if (username != null && password != null) {
        Admin admin = adminService.findByUsername(username);
        if (admin == null) {
            throw new UnknownAccountException();
        }
        if (!admin.getIsEnabled()) {
            throw new DisabledAccountException();
        }
        Setting setting = SettingUtils.get();
        if (admin.getIsLocked()) {
            if (ArrayUtils.contains(setting.getAccountLockTypes(), AccountLockType.admin)) {
                int loginFailureLockTime = setting.getAccountLockTime();
                if (loginFailureLockTime == 0) {
                    throw new LockedAccountException();
                }
                Date lockedDate = admin.getLockedDate();
                Date unlockDate = DateUtils.addMinutes(lockedDate, loginFailureLockTime);
                if (new Date().after(unlockDate)) {
                    admin.setLoginFailureCount(0);
                    admin.setIsLocked(false);
                    admin.setLockedDate(null);
                    adminService.update(admin);
                } else {
                    throw new LockedAccountException();
                }
            } else {
                admin.setLoginFailureCount(0);
                admin.setIsLocked(false);
                admin.setLockedDate(null);
                adminService.update(admin);
            }
        }
        if (!DigestUtils.md5Hex(password).equals(admin.getPassword())) {
            int loginFailureCount = admin.getLoginFailureCount() + 1;
            if (loginFailureCount >= setting.getAccountLockCount()) {
                admin.setIsLocked(true);
                admin.setLockedDate(new Date());
            }
            admin.setLoginFailureCount(loginFailureCount);
            adminService.update(admin);
            throw new IncorrectCredentialsException();
        }
        admin.setLoginIp(ip);
        admin.setLoginDate(new Date());
        admin.setLoginFailureCount(0);
        adminService.update(admin);
        return new SimpleAuthenticationInfo(new Principal(admin.getId(), username), password, getName());
    }
    throw new UnknownAccountException();
}

From source file:com.dp2345.AuthenticationRealm.java

/**
 * ???//from w  ww  .  ja v  a2s  . c  o m
 * 
 * @param token
 *            
 * @return ??
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token) {
    AuthenticationToken authenticationToken = (AuthenticationToken) token;
    String username = authenticationToken.getUsername();
    String password = new String(authenticationToken.getPassword());
    String captchaId = authenticationToken.getCaptchaId();
    String captcha = authenticationToken.getCaptcha();
    String ip = authenticationToken.getHost();
    if (!captchaService.isValid(CaptchaType.adminLogin, captchaId, captcha)) {
        throw new UnsupportedTokenException();
    }
    if (username != null && password != null) {
        Admin admin = adminService.findByUsername(username);
        if (admin == null) {
            throw new UnknownAccountException();
        }
        if (!admin.getIsEnabled()) {
            throw new DisabledAccountException();
        }
        Setting setting = SettingUtils.get();
        if (admin.getIsLocked()) {
            if (ArrayUtils.contains(setting.getAccountLockTypes(), AccountLockType.admin)) {
                int loginFailureLockTime = setting.getAccountLockTime();
                if (loginFailureLockTime == 0) {
                    throw new LockedAccountException();
                }
                Date lockedDate = admin.getLockedDate();
                Date unlockDate = DateUtils.addMinutes(lockedDate, loginFailureLockTime);
                if (new Date().after(unlockDate)) {
                    admin.setLoginFailureCount(0);
                    admin.setIsLocked(false);
                    admin.setLockedDate(null);
                    adminService.update(admin);
                } else {
                    throw new LockedAccountException();
                }
            } else {
                admin.setLoginFailureCount(0);
                admin.setIsLocked(false);
                admin.setLockedDate(null);
                adminService.update(admin);
            }
        }
        if (!DigestUtils.md5Hex(password).equals(admin.getPassword())) {
            int loginFailureCount = admin.getLoginFailureCount() + 1;
            if (loginFailureCount >= setting.getAccountLockCount()) {
                admin.setIsLocked(true);
                admin.setLockedDate(new Date());
            }
            admin.setLoginFailureCount(loginFailureCount);
            adminService.update(admin);
            throw new IncorrectCredentialsException();
        }
        admin.setLoginIp(ip);
        admin.setLoginDate(new Date());
        admin.setLoginFailureCount(0);
        adminService.update(admin);
        return new SimpleAuthenticationInfo(new Principal(admin.getId(), username), password, getName());
    }
    throw new UnknownAccountException();
}