List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:info.magnolia.security.app.dialog.field.validator.UniqueUserNameValidator.java
@Override protected boolean isValidValue(String value) { if (item instanceof JcrNodeAdapter) { // If we're editing an existing node then its allowed to use the current username of course if (!(item instanceof JcrNewNodeAdapter)) { try { String currentName = ((JcrNodeAdapter) item).getJcrItem().getName(); if (StringUtils.equals(value, currentName)) { return true; }/*from w ww.j a va 2 s.c o m*/ } catch (RepositoryException e) { log.error("Exception occurred getting node name of node [{}]", ((JcrNodeAdapter) item).getItemId(), e); return false; } } // In the case of JcrNewNodeAdapter this is path of the parent node, but that's enough String path; try { path = ((JcrNodeAdapter) item).getJcrItem().getPath(); } catch (RepositoryException e) { log.error("Exception getting path of node [{}]", ((JcrNodeAdapter) item).getItemId(), e); return false; } UserManager userManager = securitySupport.getUserManager(getRealmName(path)); if (!(userManager instanceof MgnlUserManager) || !((MgnlUserManager) userManager).isAllowCrossRealmDuplicateNames()) { // if allow duplicate names across realms is not supported by usermanager or when it's disallowed userManager = securitySupport.getUserManager(); } // Check if user with such name already exists if (userManager.getUser(value) == null) { return true; } } return false; }
From source file:io.wcm.config.core.impl.ParameterProviderBridge.java
@Override public ConfigurationMetadata getConfigurationMetadata(String configName) { if (StringUtils.equals(configName, DEFAULT_CONFIG_NAME)) { return configMetadata; } else {// w w w . j a va2 s . c o m return null; } }
From source file:com.glaf.base.district.web.springmvc.DistrictController.java
@ResponseBody @RequestMapping("/delete") public void delete(HttpServletRequest request, ModelMap modelMap) { LoginContext loginContext = RequestUtils.getLoginContext(request); Long id = RequestUtils.getLong(request, "id"); String ids = request.getParameter("ids"); if (StringUtils.isNotEmpty(ids)) { StringTokenizer token = new StringTokenizer(ids, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { DistrictEntity district = districtService.getDistrict(Long.valueOf(x)); if (district != null && (StringUtils.equals(district.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { districtService.deleteById(district.getId()); }//from www . ja v a2s . c o m } } } else if (id != null) { DistrictEntity district = districtService.getDistrict(Long.valueOf(id)); if (district != null && (StringUtils.equals(district.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { districtService.deleteById(district.getId()); } } }
From source file:com.inkubator.hrm.web.lazymodel.AppraisalCompetencyTypeLazyDataModel.java
@Override public AppraisalCompetencyType getRowData(String id) { for (AppraisalCompetencyType appraisalCompetencyType : appraisalCompetencyTypesList) { if (StringUtils.equals(id, String.valueOf(appraisalCompetencyType.getId()))) { return appraisalCompetencyType; }/*from w w w. j av a 2 s . c o m*/ } return null; }
From source file:me.leep.wf.services.system.impl.ShiroRealmImpl.java
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { System.out.println(/* w w w.ja v a2s . co m*/ " , ?loaddoGetAuthorizationInfo................."); // doGetAuthenticationInfo ? ShiroUser shiroUser = (ShiroUser) principals.fromRealm(getName()).iterator().next(); String userName = shiroUser.getName(); if (StringUtils.equals("admin", userName)) { SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); // ?<shiro:hasRole>name info.addRole("admin"); // ? <shiro:hasPermission> name info.addStringPermission("user:edit"); return info; } else if (StringUtils.equals("test", userName)) { SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); // ?<shiro:hasRole>name info.addRole("test"); // ? <shiro:hasPermission> name, ?,? info.addStringPermission("user:view"); return info; } else { return null; } }
From source file:io.wcm.samples.handler.util.AppTemplate.java
/** * Lookup a template by the given template path. * @param templatePath Path of template/*w w w . j av a 2 s . c om*/ * @return The {@link AppTemplate} instance or null for unknown template paths */ public static AppTemplate forTemplatePath(String templatePath) { for (AppTemplate template : AppTemplate.values()) { if (StringUtils.equals(template.getTemplatePath(), templatePath)) { return template; } } return null; }
From source file:ch.cyberduck.core.sds.SDSDelegatingCopyFeature.java
@Override public void copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if (containerService.getContainer(target).getType().contains(Path.Type.vault)) { final FileKey fileKey = TripleCryptConverter.toSwaggerFileKey(Crypto.generateFileKey()); final ObjectWriter writer = session.getClient().getJSON().getContext(null).writerFor(FileKey.class); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try {/* w w w . j a v a2s . c o m*/ writer.writeValue(out, fileKey); } catch (IOException e) { throw new DefaultIOExceptionMappingService().map(e); } status.setFilekey(ByteBuffer.wrap(out.toByteArray())); } if (containerService.getContainer(source).getType().contains(Path.Type.vault) || containerService.getContainer(target).getType().contains(Path.Type.vault)) { new DefaultCopyFeature(session).copy(source, target, status, callback); } else { if (StringUtils.equals(source.getName(), target.getName())) { proxy.copy(source, target, status, callback); } else { new DefaultCopyFeature(session).copy(source, target, status, callback); } } }
From source file:cn.mypandora.service.TestDeptService.java
@Test public void findDeptById() { BaseDept dept = service.findDeptById(3L); assertTrue(StringUtils.equals(dept.getName(), "")); }
From source file:com.glaf.core.config.SystemConfig.java
public static String getCurrentYYYYMM() { String value = getString("curr_yyyymm"); if (StringUtils.isEmpty(value) || StringUtils.equals("curr_yyyymm", value) || StringUtils.equals(CURR_YYYYMM, value)) { Date now = new Date(); value = String.valueOf(DateUtils.getYearMonth(now)); }//from ww w . j a v a 2 s . co m return value; }
From source file:de.micromata.genome.util.matcher.cls.AnnotationAttributeClassMatcher.java
/** * Compare simple type./*from ww w . j a va 2 s. c o m*/ * * @param val the val * @return true, if successful */ protected boolean compareSimpleType(Object val) { if (val instanceof Class<?>) { return StringUtils.equals(((Class<?>) val).getCanonicalName(), fieldValue); } final String sval = val != null ? val.toString() : null; return StringUtils.equals(sval, fieldValue); }