List of usage examples for org.apache.commons.lang ArrayUtils contains
public static boolean contains(boolean[] array, boolean valueToFind)
Checks if the value is in the given array.
From source file:eu.dime.ps.semantic.privacy.PrivacyPreferenceServiceTest.java
private boolean comparePrivacyPreferences(Collection<PrivacyPreference> privacyPrefs, String[] labels) { for (PrivacyPreference privacyPref : privacyPrefs) { String prefLabel = privacyPref.getPrefLabel(); if (!ArrayUtils.contains(labels, prefLabel)) { return false; }//from w w w .java 2 s . c o m } return true; }
From source file:com.avatarproject.core.command.APTabCompleter.java
@Override public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) { List<String> complete = new ArrayList<String>(); if (cmd.getName().equalsIgnoreCase("avatar")) { if (args.length == 1) { List<String> possible = new ArrayList<String>(); for (APCommand command : APCommand.instances.values()) { if (hasPermission(sender, command.getName())) { possible.add(command.getAliases()[0]); }/*from www. j a va2 s . c o m*/ } return getPossibleCompletionsForGivenArgs(args, possible); } if (args.length > 1) { for (APCommand command : APCommand.instances.values()) { if (ArrayUtils.contains(command.getAliases(), args[0].toLowerCase())) { if (command.getCompleters() != null) { if (command.getCompleters().length >= (args.length - 1)) { String[] completers = command.getCompleters()[(args.length - 2)]; if (Arrays.asList(completers).contains("%custom")) { completers = (String[]) ArrayUtils.removeElement(completers, "%custom"); completers = (String[]) ArrayUtils.addAll(completers, command.tabComplete(sender, args)); } if (Arrays.asList(completers).contains("%player")) { completers = (String[]) ArrayUtils.removeElement(completers, "%player"); List<String> array = new ArrayList<String>(); for (Player p : Bukkit.getOnlinePlayers()) { array.add(p.getName()); } completers = (String[]) ArrayUtils.addAll(completers, array.toArray(new String[array.size()])); } return getPossibleCompletionsForGivenArgs(args, completers); } } } } } } return complete; }
From source file:eu.dime.ps.semantic.query.BasicQueryTest.java
@Test public void testNumericalComparison() throws Exception { Collection<FileDataObject> results = resourceStore.find(FileDataObject.class).where(NFO.fileSize) .gt(100000l).where(NFO.fileSize).lt(200000l).results(); assertEquals(3, results.size());/* w ww . j ava2 s . co m*/ URI[] files = new URI[] { new URIImpl("file:/home/ismriv/example/dir1/motivation-long-tail.png"), new URIImpl("file:/home/ismriv/example/dir1/screenshot-GVS.png"), new URIImpl("file:/home/ismriv/example/dir2/lego.png") }; for (FileDataObject f : results) { assertTrue(ArrayUtils.contains(files, f.asURI())); } }
From source file:com.eviware.soapui.impl.actions.RestServiceBuilder.java
protected RestResource createResource(ModelCreationStrategy creationStrategy, WsdlProject project, String URI) throws MalformedURLException { RestURIParser restURIParser = new RestURIParserImpl(URI); String resourcePath = restURIParser.getResourcePath(); String host = restURIParser.getEndpoint(); RestService restService = null;//ww w . ja v a2s . c o m if (creationStrategy == ModelCreationStrategy.REUSE_MODEL) { AbstractInterface<?> existingInterface = project.getInterfaceByName(host); if (existingInterface instanceof RestService && ArrayUtils.contains(existingInterface.getEndpoints(), host)) { restService = (RestService) existingInterface; } } if (restService == null) { restService = (RestService) project.addNewInterface(host, RestServiceFactory.REST_TYPE); restService.addEndpoint(restURIParser.getEndpoint()); } if (creationStrategy == ModelCreationStrategy.REUSE_MODEL) { RestResource existingResource = restService .getResourceByFullPath(RestResource.removeMatrixParams(resourcePath)); if (existingResource != null) { return existingResource; } } return restService.addNewResource(restURIParser.getResourceName(), resourcePath); }
From source file:edu.illinois.cs.cogcomp.edison.features.lrec.TestAffixes.java
public final void test() throws EdisonException { log.debug("Affixes Feature Extractor"); // Using the first TA and a constituent between span of 30-40 as a test TextAnnotation ta = tas.get(1);//from w ww . j av a 2s . c om View TOKENS = ta.getView("TOKENS"); log.debug("Got tokens FROM TextAnnotation"); List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20); for (Constituent c : testlist) { log.debug(c.getSurfaceForm()); } log.debug("Test Input size is " + testlist.size()); Constituent test = testlist.get(1); log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm()); Affixes afx = new Affixes("Affixes"); log.debug("Startspan is " + test.getStartSpan() + " and Endspan is " + test.getEndSpan()); Set<Feature> feats = afx.getFeatures(test); String[] expected_outputs = { "Affixes:p|(giv)", "Affixes:s|(e)", "Affixes:s|(ve)", "Affixes:s|(ive)" }; if (feats == null) { log.debug("Feats are returning NULL."); } log.debug("Printing Set of Features"); for (Feature f : feats) { log.debug(f.getName()); assert (ArrayUtils.contains(expected_outputs, f.getName())); } }
From source file:com.hyeb.back.authenticate.AuthenticationRealm.java
/** * ???/*from w w w . j av a 2s .c o m*/ * * @param token * * @return ?? */ @Override protected AuthenticationInfo doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token) { SysUserService sysUserService = (SysUserService) SpringUtils.getBean("sysUserServiceImpl"); 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) { SysUser sysUser = sysUserService.findByUsername(username); if (sysUser == null) { throw new UnknownAccountException(); } if (!sysUser.getIsEnabled()) { throw new DisabledAccountException(); } Setting setting = SettingUtils.get(); if (sysUser.getIsLocked()) { if (ArrayUtils.contains(setting.getAccountLockTypes(), AccountLockType.admin)) { int loginFailureLockTime = setting.getAccountLockTime(); if (loginFailureLockTime == 0) { throw new LockedAccountException(); } Date lockedDate = sysUser.getLockedDate(); Date unlockDate = DateUtils.addMinutes(lockedDate, loginFailureLockTime); if (new Date().after(unlockDate)) { sysUser.setLoginFailureCount(0); sysUser.setIsLocked(false); sysUser.setLockedDate(null); sysUserService.update(sysUser); } else { throw new LockedAccountException(); } } else { sysUser.setLoginFailureCount(0); sysUser.setIsLocked(false); sysUser.setLockedDate(null); sysUserService.update(sysUser); } } if (!DigestUtils.md5Hex(password).equals(sysUser.getPassword())) { int loginFailureCount = sysUser.getLoginFailureCount() + 1; if (loginFailureCount >= setting.getAccountLockCount()) { sysUser.setIsLocked(true); sysUser.setLockedDate(new Date()); } sysUser.setLoginFailureCount(loginFailureCount); sysUserService.update(sysUser); throw new IncorrectCredentialsException(); } sysUser.setLoginIp(ip); sysUser.setLoginDate(new Date()); sysUser.setLoginFailureCount(0); sysUserService.update(sysUser); SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo( new Principal(sysUser.getId(), username), password, getName()); return simpleAuthenticationInfo; } throw new UnknownAccountException(); }
From source file:info.magnolia.importexport.filters.MetadataUuidFilter.java
/** * Skip unwanted name spaces, see MAGNOLIA-2756. *//* w w w. j av a 2s.c o m*/ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { if (!removeUnwantedNamespaces || ArrayUtils.contains(validNs, prefix)) { super.startPrefixMapping(prefix, uri); } else { inSkippedNs = true; } }
From source file:com.pureinfo.srm.view.function.ShowReserchCenterSelectorFunctionHandler.java
private String makeOptions(Object[][] _sOrgDatas, Integer[] _sValues) { StringBuffer sbuff = new StringBuffer(); for (int i = 0; i < _sOrgDatas[0].length; i++) { sbuff.append("<OPTION value=\"").append(_sOrgDatas[0][i]).append("\""); if (ArrayUtils.contains(_sValues, _sOrgDatas[0][i])) { sbuff.append(" SELECTED"); }//from w w w . ja v a 2 s. com sbuff.append(">").append(_sOrgDatas[1][i]).append("\n"); } return sbuff.toString(); }
From source file:com.puyuntech.flowerToHome.controller.admin.LoginController.java
/** * //from ww w . j ava 2 s.co m * ?. author: date: 2015-9-21 ?1:29:55 * * @param request * ?? * @param model * ? * @return ?? */ @RequestMapping public String index(HttpServletRequest request, ModelMap model) { /** * */ String loginToken = WebUtils.getCookie(request, Admin.LOGIN_TOKEN_COOKIE_NAME); /** * ? */ if (!StringUtils.equalsIgnoreCase(loginToken, adminService.getLoginToken())) { return "redirect:/"; } /** * ??? */ if (adminService.isAuthenticated()) { return "redirect:common/main.jhtml"; } Message failureMessage = null; /** * */ String loginFailure = (String) request .getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME); if (StringUtils.isNotEmpty(loginFailure)) { if (loginFailure.equals("com.puyuntech.ycmall.exception.IncorrectCaptchaException")) { failureMessage = Message.error("admin.captcha.invalid"); } else if (loginFailure.equals("org.apache.shiro.authc.UnknownAccountException")) { failureMessage = Message.error("admin.login.unknownAccount"); } else if (loginFailure.equals("org.apache.shiro.authc.DisabledAccountException")) { failureMessage = Message.error("admin.login.disabledAccount"); } else if (loginFailure.equals("org.apache.shiro.authc.LockedAccountException")) { failureMessage = Message.error("admin.login.lockedAccount"); } else if (loginFailure.equals("org.apache.shiro.authc.IncorrectCredentialsException")) { Setting setting = SystemUtils.getSetting(); if (ArrayUtils.contains(setting.getAccountLockTypes(), Setting.AccountLockType.admin)) { failureMessage = Message.error("admin.login.accountLockCount", setting.getAccountLockCount()); } else { failureMessage = Message.error("admin.login.incorrectCredentials"); } } else if (loginFailure.equals("com.puyuntech.ycmall.exception.IllegalLicenseException")) { failureMessage = Message.error("admin.login.incorrectLicense"); } else if (loginFailure.equals("org.apache.shiro.authc.AuthenticationException")) { failureMessage = Message.error("admin.login.authentication"); } } /** * ? */ RSAPublicKey publicKey = rsaService.generateKey(request); /** * ? */ model.addAttribute("modulus", Base64.encodeBase64String(publicKey.getModulus().toByteArray())); model.addAttribute("exponent", Base64.encodeBase64String(publicKey.getPublicExponent().toByteArray())); model.addAttribute("captchaId", request.getSession().getId()); model.addAttribute("failureMessage", failureMessage); return "/admin/login/index"; }
From source file:gda.device.scannable.BeamlineConditionMonitorBase.java
/** * Returns false if not in a real running mode. * /* ww w .j a v a2s . c o m*/ * @return true if user mode, so this object should operate. * @throws DeviceException */ protected boolean machineIsRunning() throws DeviceException { if (machineModeMonitor == null) { return false; } try { String value = machineModeMonitor.getPosition().toString(); return !ArrayUtils.contains(modesToIgnore, value); } catch (DeviceException e) { throw new DeviceException(e.getMessage(), e); } }