List of usage examples for org.springframework.util StringUtils toStringArray
public static String[] toStringArray(@Nullable Enumeration<String> enumeration)
From source file:org.mybatis.spring.annotation.MapperScannerRegistrar.java
/** * {@inheritDoc}//ww w.ja v a 2s .c o m */ @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AnnotationAttributes annoAttrs = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName())); ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry); // this check is needed in Spring 3.1 if (resourceLoader != null) { scanner.setResourceLoader(resourceLoader); } Class<? extends Annotation> annotationClass = annoAttrs.getClass("annotationClass"); if (!Annotation.class.equals(annotationClass)) { scanner.setAnnotationClass(annotationClass); } Class<?> markerInterface = annoAttrs.getClass("markerInterface"); if (!Class.class.equals(markerInterface)) { scanner.setMarkerInterface(markerInterface); } Class<? extends BeanNameGenerator> generatorClass = annoAttrs.getClass("nameGenerator"); if (!BeanNameGenerator.class.equals(generatorClass)) { scanner.setBeanNameGenerator(BeanUtils.instantiateClass(generatorClass)); } Class<? extends MapperFactoryBean> mapperFactoryBeanClass = annoAttrs.getClass("factoryBean"); if (!MapperFactoryBean.class.equals(mapperFactoryBeanClass)) { scanner.setMapperFactoryBean(BeanUtils.instantiateClass(mapperFactoryBeanClass)); } scanner.setSqlSessionTemplateBeanName(annoAttrs.getString("sqlSessionTemplateRef")); scanner.setSqlSessionFactoryBeanName(annoAttrs.getString("sqlSessionFactoryRef")); List<String> basePackages = new ArrayList<String>(); for (String pkg : annoAttrs.getStringArray("value")) { if (StringUtils.hasText(pkg)) { basePackages.add(pkg); } } for (String pkg : annoAttrs.getStringArray("basePackages")) { if (StringUtils.hasText(pkg)) { basePackages.add(pkg); } } for (Class<?> clazz : annoAttrs.getClassArray("basePackageClasses")) { basePackages.add(ClassUtils.getPackageName(clazz)); } scanner.registerFilters(); scanner.doScan(StringUtils.toStringArray(basePackages)); }
From source file:edu.mayo.cts2.framework.webapp.rest.osgi.OsgiAnnotationHandlerMapping.java
protected String[] determineUrlsForOsgiService(Object osgiController) { Class<?> handlerType = osgiController.getClass(); RequestMapping mapping = osgiController.getClass().getAnnotation(RequestMapping.class); if (mapping != null) { // @RequestMapping found at type level this.cachedMappings.put(handlerType, mapping); Set<String> urls = new LinkedHashSet<String>(); String[] typeLevelPatterns = mapping.value(); if (typeLevelPatterns.length > 0) { // @RequestMapping specifies paths at type level String[] methodLevelPatterns = determineUrlsForHandlerMethods(handlerType, true); for (String typeLevelPattern : typeLevelPatterns) { if (!typeLevelPattern.startsWith("/")) { typeLevelPattern = "/" + typeLevelPattern; }//from ww w . j av a 2s .c om boolean hasEmptyMethodLevelMappings = false; for (String methodLevelPattern : methodLevelPatterns) { if (methodLevelPattern == null) { hasEmptyMethodLevelMappings = true; } else { String combinedPattern = getPathMatcher().combine(typeLevelPattern, methodLevelPattern); addUrlsForPath(urls, combinedPattern); } } if (hasEmptyMethodLevelMappings || org.springframework.web.servlet.mvc.Controller.class.isAssignableFrom(handlerType)) { addUrlsForPath(urls, typeLevelPattern); } } return StringUtils.toStringArray(urls); } else { // actual paths specified by @RequestMapping at method level return determineUrlsForHandlerMethods(handlerType, false); } } else if (AnnotationUtils.findAnnotation(handlerType, Controller.class) != null) { // @RequestMapping to be introspected at method level return determineUrlsForHandlerMethods(handlerType, false); } else { return null; } }
From source file:lodsve.core.condition.OnBeanCondition.java
private String[] getBeanNamesForAnnotation(ConfigurableListableBeanFactory beanFactory, String type, ClassLoader classLoader, boolean considerHierarchy) throws LinkageError { String[] result = NO_BEANS;/*from w w w . j a va 2 s . c o m*/ try { @SuppressWarnings("unchecked") Class<? extends Annotation> typeClass = (Class<? extends Annotation>) ClassUtils.forName(type, classLoader); result = beanFactory.getBeanNamesForAnnotation(typeClass); if (considerHierarchy) { if (beanFactory.getParentBeanFactory() instanceof ConfigurableListableBeanFactory) { String[] parentResult = getBeanNamesForAnnotation( (ConfigurableListableBeanFactory) beanFactory.getParentBeanFactory(), type, classLoader, true); List<String> resultList = new ArrayList<String>(); resultList.addAll(Arrays.asList(result)); for (String beanName : parentResult) { if (!resultList.contains(beanName) && !beanFactory.containsLocalBean(beanName)) { resultList.add(beanName); } } result = StringUtils.toStringArray(resultList); } } return result; } catch (ClassNotFoundException ex) { return NO_BEANS; } }
From source file:com.jaspersoft.jasperserver.war.control.SystemErrorController.java
public SystemErrorController() { final List<String> supportedMethodsList = new ArrayList<String>(Arrays.asList(getSupportedMethods())); supportedMethodsList.add("DELETE"); supportedMethodsList.add("PUT"); setSupportedMethods(StringUtils.toStringArray(supportedMethodsList)); }
From source file:net.yasion.common.core.bean.wrapper.impl.ExtendedBeanWrapperImpl.java
/** * Parse the given property name into the corresponding property name tokens. * /* w w w. j a v a 2 s . co m*/ * @param propertyName * the property name to parse * @return representation of the parsed property tokens */ private PropertyTokenHolder getPropertyNameTokens(String propertyName) { PropertyTokenHolder tokens = new PropertyTokenHolder(); String actualName = null; List<String> keys = new ArrayList<String>(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); searchIndex = -1; if (keyStart != -1) { int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length()); if (keyEnd != -1) { if (actualName == null) { actualName = propertyName.substring(0, keyStart); } String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd); if ((key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) { key = key.substring(1, key.length() - 1); } keys.add(key); searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length(); } } } tokens.actualName = (actualName != null ? actualName : propertyName); tokens.canonicalName = tokens.actualName; if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys); } return tokens; }
From source file:org.ednovo.gooru.domain.service.user.impl.UserServiceImpl.java
private UserCredential getUserCredential(User user, final String key, String sharedSecretKey) { String userCredentailKey = "user-credential:" + ((key != null && !key.equalsIgnoreCase(NA)) ? key : user.getGooruUId()); List<String> authorities = new ArrayList<String>(); if (user != null && user.getUserRoleSet() != null && user.getUserRoleSet().size() > 0) { for (UserRoleAssoc userRoleAssoc : user.getUserRoleSet()) { for (RoleEntityOperation roleEntityOperation : userRoleAssoc.getRole().getRoleOperations()) { EntityOperation entityOperation = roleEntityOperation.getEntityOperation(); String authority = entityOperation.getEntityName() + GooruOperationConstants.ENTITY_ACTION_SEPARATOR + entityOperation.getOperationName(); if (!authorities.contains(authority)) { authorities.add(authority); }/*from w w w. ja v a 2 s . c o m*/ } } } List<String> userParties = new ArrayList<String>(); List<String> partyPrivileges = new ArrayList<String>(); List<String> userOrgs = new ArrayList<String>(); List<String> organizationIdList = new ArrayList<String>(); List<String> userSuborgs = new ArrayList<String>(); organizationIdList.add(user.getOrganization().getPartyUid()); Map<String, String> permittedParties = new HashMap<String, String>(); PartyPermission partyPermission = new PartyPermission(); partyPermission.setParty(user); getSubOrganizations(userSuborgs, organizationIdList); Map<String, Set<String>> partyPermissionsMap = new HashMap<String, Set<String>>(); getUserParties(partyPermission, permittedParties, userParties, userOrgs, partyPrivileges); UserCredential userCredential = new UserCredential(); userOrgs.addAll(userSuborgs); String isAdminContentAccess = settingService.getOrganizationSetting(ConfigConstants.ADMIN_CONTENT_ACCESS, user.getOrganization().getPartyUid()); if (isAdminContentAccess != null && isAdminContentAccess.equalsIgnoreCase(ONE) && isContentAdmin(user)) { userCredential.setIsAdminAccessContent(true); } else { userCredential.setIsAdminAccessContent(false); } userCredential.setOrganizationUid(user.getOrganization().getPartyUid()); userCredential.setPrimaryOrganizatoinUid(user.getPrimaryOrganization().getPartyUid()); if (user.getUserGroup() != null) { userCredential.setDefaultGroupUid(user.getUserGroup().getPartyUid()); } userParties.add(userCredential.getOrganizationUid()); userOrgs.add(userCredential.getOrganizationUid()); // Given Access for Gooru content since it's open String isGooruContentAccess = settingService.getOrganizationSetting(ConfigConstants.ACCESS_GOORU_CONTENT, user.getOrganization().getPartyUid()); if (isGooruContentAccess != null && isGooruContentAccess.equalsIgnoreCase(ONE)) { Organization gooruOrganization = organizationService.getOrganizationByCode(GOORU); if (gooruOrganization != null && !userOrgs.contains(gooruOrganization.getPartyUid())) { userOrgs.add(gooruOrganization.getPartyUid()); } } List<PartyPermission> partyPermissions = groupRepository.getUserPartyPermissions(user.getPartyUid()); if (partyPermissions.size() > 0) { for (PartyPermission subPartyPermission : partyPermissions) { Set<String> permissions = partyPermissionsMap .get(subPartyPermission.getParty().getPartyUid()) == null ? new HashSet<String>() : partyPermissionsMap.get(subPartyPermission.getParty().getPartyUid()); permissions.add(subPartyPermission.getPermission()); partyPermissionsMap.put(subPartyPermission.getParty().getPartyUid(), permissions); } } String[] userPartiesAsArray = StringUtils.toStringArray(userParties); String[] userOrgsAsArray = StringUtils.toStringArray(userOrgs); String[] userSubOrgsArray = StringUtils.toStringArray(userSuborgs); userCredential.setPartyPermits(userPartiesAsArray); userCredential.setOrgPermits(userOrgsAsArray); userCredential.setPartyPermitsAsString( "'" + org.apache.commons.lang.StringUtils.join(userPartiesAsArray, "','") + "'"); userCredential.setOrgPermitsAsString( "'" + org.apache.commons.lang.StringUtils.join(userOrgsAsArray, "','") + "'"); userCredential.setSubOrganizationUidsString( "'" + org.apache.commons.lang.StringUtils.join(userSubOrgsArray, "','") + "'"); userCredential.setKey(userCredentailKey); userCredential.setUserUid(user.getPartyUid()); userCredential.setToken(key); userCredential.setOperationAuthorities(authorities); userCredential.setOrganizationNfsInternalPath(user.getOrganization().getNfsStorageArea().getInternalPath()); userCredential.setOrganizationNfsRealPath(user.getOrganization().getNfsStorageArea().getAreaPath()); userCredential.setPartyOperations(partyPrivileges); userCredential.setSubOrganizationUids(userSuborgs); userCredential.setOrganizationCdnDirectPath(user.getOrganization().getNfsStorageArea().getCdnDirectPath()); userCredential.setSharedSecretKey(sharedSecretKey); userCredential.setProfileAssetURI(BaseUtil.changeHttpsProtocolByHeader(settingService .getConfigSetting(ConfigConstants.PROFILE_IMAGE_URL, user.getOrganization().getPartyUid())) + "/"); String storedSecret = settingService.getOrganizationSetting(ConstantProperties.SUPER_ADMIN_TOKEN, TaxonomyUtil.GOORU_ORG_UID); userCredential.setPartyPermissions(partyPermissionsMap); userCredential.setStoredSecretKey(storedSecret); UserToken userToken = userTokenRepository.findByToken(key); if (userToken != null && userToken.getApplication() != null) { userCredential.setApiKeySearchLimit(userToken.getApplication().getSearchLimit()); } PartyCustomField partyCustomFieldTax = partyService.getPartyCustomeField(user.getPartyUid(), USER_TAXONOMY_ROOT_CODE, null); if (partyCustomFieldTax != null) { userCredential.setTaxonomyPreference(partyCustomFieldTax.getOptionalValue()); } else { this.getTaxonomyRespository().getFindTaxonomyList(settingService.getConfigSetting( ConfigConstants.GOORU_EXCLUDE_TAXONOMY_PREFERENCE, 0, user.getOrganization().getPartyUid())); } return userCredential; }
From source file:org.springframework.beans.AbstractNestablePropertyAccessor.java
/** * Parse the given property name into the corresponding property name tokens. * @param propertyName the property name to parse * @return representation of the parsed property tokens */// w w w .j a v a2 s . co m private PropertyTokenHolder getPropertyNameTokens(String propertyName) { String actualName = null; List<String> keys = new ArrayList<>(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); searchIndex = -1; if (keyStart != -1) { int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length()); if (keyEnd != -1) { if (actualName == null) { actualName = propertyName.substring(0, keyStart); } String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd); if (key.length() > 1 && (key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) { key = key.substring(1, key.length() - 1); } keys.add(key); searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length(); } } } PropertyTokenHolder tokens = new PropertyTokenHolder(actualName != null ? actualName : propertyName); if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys); } return tokens; }
From source file:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.java
/** * Return an array of non-simple bean properties that are unsatisfied. * These are probably unsatisfied references to other beans in the * factory. Does not include simple properties like primitives or Strings. * @param mbd the merged bean definition the bean was created with * @param bw the BeanWrapper the bean was created with * @return an array of bean property names * @see org.springframework.beans.BeanUtils#isSimpleProperty *///from w w w. j a v a 2 s .c o m protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, BeanWrapper bw) { Set<String> result = new TreeSet<>(); PropertyValues pvs = mbd.getPropertyValues(); PropertyDescriptor[] pds = bw.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null && !isExcludedFromDependencyCheck(pd) && !pvs.contains(pd.getName()) && !BeanUtils.isSimpleProperty(pd.getPropertyType())) { result.add(pd.getName()); } } return StringUtils.toStringArray(result); }
From source file:org.springframework.beans.factory.support.AbstractBeanFactory.java
public String[] getAliases(String name) throws NoSuchBeanDefinitionException { String beanName = transformedBeanName(name); // Check if bean actually exists in this bean factory. if (containsSingleton(beanName) || containsBeanDefinition(beanName)) { // If found, gather aliases. List aliases = new ArrayList(); synchronized (this.aliasMap) { for (Iterator it = this.aliasMap.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); if (entry.getValue().equals(beanName)) { aliases.add(entry.getKey()); }/*from w w w . ja v a 2 s . c o m*/ } } return StringUtils.toStringArray(aliases); } else { // Not found -> check parent. BeanFactory parentBeanFactory = getParentBeanFactory(); if (parentBeanFactory != null) { return parentBeanFactory.getAliases(name); } throw new NoSuchBeanDefinitionException(beanName, toString()); } }
From source file:org.springframework.beans.factory.support.AbstractBeanFactory.java
/** * Return the names of beans in the singleton cache. * <p>Does not consider any hierarchy this factory may participate in. *//* ww w . j a v a 2s . c o m*/ public String[] getSingletonNames() { synchronized (this.singletonCache) { return StringUtils.toStringArray(this.singletonCache.keySet()); } }