当前位置: 首页>>代码示例>>Java>>正文


Java MapUtils类代码示例

本文整理汇总了Java中org.apache.commons.collections.MapUtils的典型用法代码示例。如果您正苦于以下问题:Java MapUtils类的具体用法?Java MapUtils怎么用?Java MapUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapUtils类属于org.apache.commons.collections包,在下文中一共展示了MapUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shiroFilter

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
@Bean
public ShiroFilterFactoryBean shiroFilter() {
	ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
	
	//设置Filter映射
	LinkedHashMap<String, Filter> filterMap = new LinkedHashMap<>();
	DefaultCasFilter casFilter = new DefaultCasFilter();
	casFilter.setFailureUrl(loginProperties.getFailureUrl()); //配置验证错误时的失败页面
	casFilter.setReloginUrl(loginProperties.getCasLogin() + "&msg={0}"); //验证错误后显示登录页面,并提示错误信息。只试用于ErrorContext异常
	casFilter.setLogoutUrl(loginProperties.getCasLogout());
	filterMap.put("casFilter", casFilter);
	LogoutFilter logoutFilter = new LogoutFilter();
	logoutFilter.setRedirectUrl(loginProperties.getCasLogout() + "?service=" + loginProperties.getCasLogoutCallback());
	filterMap.put("logoutFilter", logoutFilter);
	filterMap.put("perms", new DefaultPermissionsAuthorizationFilter());
	filterMap.put("authc", new DefaultFormAuthenticationFilter());
	filterMap.put("sense", new SenseLoginFilter());
	factoryBean.setFilters(filterMap);
	
	factoryBean.setSecurityManager(securityManager());
	factoryBean.setLoginUrl(loginProperties.getCasLogin());
	factoryBean.setUnauthorizedUrl(loginProperties.getUnauthorizedUrl());
	//加载权限配置
	Ini ini = new Ini();
	ini.loadFromPath(loginProperties.getShiroFilterFile());
	//did they explicitly state a 'urls' section?  Not necessary, but just in case:
	Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
	if (MapUtils.isEmpty(section)) {
		//no urls section.  Since this _is_ a urls chain definition property, just assume the
		//default section contains only the definitions:
		section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
	}
	factoryBean.setFilterChainDefinitionMap(section);
	return factoryBean;
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:36,代码来源:ShiroConfig.java

示例2: configRoleResources

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
/**
 * 配置角色-资源关系
 * @param request
 * @param response
 * @param parameter
 * @return
 */
@RequestMapping(value="/admin/role/config/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON)
@HttpAccessLogging(title="系统管理/角色管理/配置角色资源关系")
public Object configRoleResources(HttpServletRequest request, HttpServletResponse response,  @RequestBody Map<String,Object> parameter) {
	List<Long> resourceIdList = new ArrayList<Long>();
	String resourceIds = MapUtils.getString(parameter, "resourceIds");
	Long roleId = MapUtils.getLong(parameter, "roleId");
	if(!StringUtils.isEmpty(resourceIds)){
		String[] resourceIdArray = resourceIds.split(",");
		if(resourceIdArray != null && resourceIdArray.length > 0){
			for(String resourceId : resourceIdArray){
				resourceIdList.add(Long.valueOf(resourceId));
			}
		}
	}
	LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
	adminRoleService.configRoleResources(roleId, resourceIdList, loginToken.getLoginId(), DateTimeUtils.formatNow());
	return genSuccessResult("配置成功!", null);
}
 
开发者ID:penggle,项目名称:xproject,代码行数:26,代码来源:AdminRoleMgtController.java

示例3: isDefined

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
/**
 * 判断对象是不是定义了 <br>
 * List的话,不为NULL和空<br>
 * 字符串的的话,不为NULL或空<br>
 * Integer的话,不为NULL或0<br>
 * 
 * @param obj
 *            要判断的对象
 * @return 是否定义了
 */
public static boolean isDefined(Object obj) {
    if (obj instanceof Collection) {
        return CollectionUtils.isNotEmpty((Collection<?>) obj);
    }

    if (obj instanceof Map) {
        return MapUtils.isNotEmpty((Map<?, ?>) obj);
    }

    if (obj instanceof String) {
        return StringUtils.isNotEmpty((String) obj);
    }

    if (obj instanceof Integer) {
        return obj != null && (Integer) obj != 0;
    }

    return obj != null;
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:30,代码来源:Utils.java

示例4: createEventParams

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
/**
 * 创建Webhook事件参数
 *
 * @param webhookId
 * @param eventType
 * @param paramMap
 * @return
 */
public List<WebhookEventParam> createEventParams(int webhookId, int eventType, Map<String, String> paramMap) {
    if (MapUtils.isEmpty(paramMap)) {
        return Collections.emptyList();
    }

    List<WebhookEventParam> webhookEventParams = new ArrayList<>();
    WebhookEventParam webhookEventParam = null;
    for (Map.Entry<String, String> entry : paramMap.entrySet()) {
        webhookEventParam = newWebhookEventParam(webhookId, eventType, entry.getKey(), entry.getValue());
        webhookEventParams.add(webhookEventParam);
    }
    if (CollectionUtils.isNotEmpty(webhookEventParams)) {
        eventParamMapper.batchInsert(webhookEventParams);
    }
    return webhookEventParams;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:25,代码来源:HookStoreService.java

示例5: createRequestParams

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
/**
 * 创建Webhook请求参数
 *
 * @param webhookId
 * @param paramMap
 * @return
 */
public List<WebhookRequestParam> createRequestParams(int webhookId, Map<String, String> paramMap) {
    if (MapUtils.isEmpty(paramMap)) {
        return Collections.emptyList();
    }

    List<WebhookRequestParam> webhookRequestParams = new ArrayList<>();
    WebhookRequestParam webhookRequestParam = null;
    for (Map.Entry<String, String> entry : paramMap.entrySet()) {
        webhookRequestParam = newWebhookRequestParam(webhookId, entry.getKey(), entry.getValue());
        webhookRequestParams.add(webhookRequestParam);
    }
    if (CollectionUtils.isNotEmpty(webhookRequestParams)) {
        webhookRequestParamMapper.batchInsert(webhookRequestParams);
    }
    return webhookRequestParams;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:24,代码来源:HookStoreService.java

示例6: getAccessUser

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
protected AdminUser getAccessUser(HttpServletRequest request, LoggingContext loggingContext) {
	if(loggingContext.getHttpAccessLogging().isLogin()){ //用户正在登录
		HandlerMethod handlerMethod = loggingContext.getHandlerMethod();
		MethodParameter[] methodParameters = handlerMethod.getMethodParameters();
		if(methodParameters != null){
			for(MethodParameter methodParameter : methodParameters){
				if(methodParameter.hasParameterAnnotation(RequestBody.class) && AdminUser.class.equals(methodParameter.getParameterType())){
					HttpRequestParameter requestParameter = loggingContext.getHttpAccessLog().getRequestParameter();
					Object requestBody = requestParameter.getBody();
					MediaType contentType = loggingContext.getHttpAccessLog().getRequestContentType();
					if (contentType != null && requestBody != null && requestBody instanceof Map && MediaType.APPLICATION_JSON.getType().equals(contentType.getType())) {
						Map<String,Object> requestBodyMap = (Map<String, Object>) requestBody;
						return adminUserService.getUserByUserName(MapUtils.getString(requestBodyMap, "userName"), false);
					}
				}
			}
		}
		return null;
	}else{ //用户已登录
		LoginToken<AdminUser> loginToken = (LoginToken<AdminUser>) ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
		return loginToken == null ? null : loginToken.getLoginUser();
	}
}
 
开发者ID:penggle,项目名称:xproject,代码行数:24,代码来源:DefaultHttpAccessLoggingInterceptor.java

示例7: addUserRoles

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
/**
 * 添加用户-角色配置
 * @param request
 * @param response
 * @param userId
 * @param roleIds
 * @return
 */
@RequestMapping(value="/admin/user/config/add", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON)
@HttpAccessLogging(title="系统管理/用户管理/添加用户角色配置")
public Object addUserRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String,Object> parameter) {
	Long userId = MapUtils.getLong(parameter, "userId");
	String roleIds = MapUtils.getString(parameter, "roleIds");
	List<Long> roleIdList = new ArrayList<Long>();
	if(!StringUtils.isEmpty(roleIds)){
		String[] roleIdArray = roleIds.split(",");
		if(roleIdArray != null && roleIdArray.length > 0){
			for(String roleId : roleIdArray){
				roleIdList.add(Long.valueOf(roleId));
			}
		}
	}
	
	LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
	AdminUser user = new AdminUser();
	user.setUserId(userId);
	adminUserService.addUserRoles(user, roleIdList, loginToken.getLoginId(), DateTimeUtils.formatNow());
	return genSuccessResult("添加成功!", null);
}
 
开发者ID:penggle,项目名称:xproject,代码行数:30,代码来源:AdminUserMgtController.java

示例8: delUserRoles

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
/**
 * 删除户-角色配置
 * @param request
 * @param response
 * @param userId
 * @param roleIds
 * @return
 */
@RequestMapping(value="/admin/user/config/del", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON)
@HttpAccessLogging(title="系统管理/用户管理/删除用户角色配置")
public Object delUserRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String,Object> parameter) {
	Long userId = MapUtils.getLong(parameter, "userId");
	String roleIds = MapUtils.getString(parameter, "roleIds");
	List<Long> roleIdList = new ArrayList<Long>();
	if(!StringUtils.isEmpty(roleIds)){
		String[] roleIdArray = roleIds.split(",");
		if(roleIdArray != null && roleIdArray.length > 0){
			for(String roleId : roleIdArray){
				roleIdList.add(Long.valueOf(roleId));
			}
		}
	}
	AdminUser user = new AdminUser();
	user.setUserId(userId);
	adminUserService.delUserRoles(user, roleIdList);
	return genSuccessResult("删除成功!", null);
}
 
开发者ID:penggle,项目名称:xproject,代码行数:28,代码来源:AdminUserMgtController.java

示例9: extractServiceMetaData

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
private Map<String, Object> extractServiceMetaData(RouteVM routeVM) {
    Objects.requireNonNull(routeVM,
        "Can't extract service metadata because routeVM is not pass");

    Map<String, String> serviceInstancesStatus = routeVM.getServiceInstancesStatus();
    if (MapUtils.isEmpty(serviceInstancesStatus)) {
        log.error("Microservice instances has no statuses");
        return null;
    }
    Map<String, Object> result = null;
    for (ServiceInstance instance : routeVM.getServiceInstances()) {
        if (instance.getUri() == null || StringUtils.isBlank(instance.getUri().toString())) {
            continue;
        }
        String uri = instance.getUri().toString();
        if ("UP".equals(serviceInstancesStatus.get(uri))) {
            if (result == null) {
                result = new HashMap<>();
            }
            result.put(uri, getInstanceInfo(uri));
        }
    }
    return result;
}
 
开发者ID:xm-online,项目名称:xm-gate,代码行数:25,代码来源:GatewayResource.java

示例10: getLocationManager

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
public SourceLocationManager getLocationManager(
    Table table,
    List<Partition> partitions,
    String eventId,
    Map<String, Object> copierOptions)
  throws IOException {
  if (MetaStoreUtils.isView(table)) {
    return new ViewLocationManager();
  }
  HdfsSnapshotLocationManager hdfsSnapshotLocationManager = new HdfsSnapshotLocationManager(getHiveConf(), eventId,
      table, partitions, snapshotsDisabled, sourceTableLocation, sourceCatalogListener);
  boolean ignoreMissingFolder = MapUtils.getBooleanValue(copierOptions,
      CopierOptions.IGNORE_MISSING_PARTITION_FOLDER_ERRORS, false);
  if (ignoreMissingFolder) {
    return new FilterMissingPartitionsLocationManager(hdfsSnapshotLocationManager, getHiveConf());
  }
  return hdfsSnapshotLocationManager;
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:19,代码来源:Source.java

示例11: afterPropertiesSet

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {

    //获取服务注册中心
    IRegisterCenter4Invoker registerCenter4Consumer = ZKRegisterCenter.singleton();
    //初始化服务提供者列表到本地缓存
    registerCenter4Consumer.initProviderMap(remoteAppKey, groupName);

    //初始化Netty Channel,providerMap提供几个服务接口就是几个
    Map<String, List<ProviderService>> providerMap = registerCenter4Consumer.getServiceMetaDataMap4Consume();
    if (MapUtils.isEmpty(providerMap)) {
        throw new RuntimeException("service provider list is empty.");
    }
    NettyChannelPoolFactory.channelPoolFactoryInstance().initChannelPoolFactory(providerMap);

    //获取服务提供者代理对象
    RevokerProxyBeanFactory proxyFactory = RevokerProxyBeanFactory.singleton(targetInterface, timeout, clusterStrategy);
    this.serviceObject = proxyFactory.getProxy();

    //将消费者信息注册到注册中心
    InvokerService invoker = new InvokerService();
    invoker.setServiceItf(targetInterface);
    invoker.setRemoteAppKey(remoteAppKey);
    invoker.setGroupName(groupName);
    registerCenter4Consumer.registerInvoker(invoker);
}
 
开发者ID:linuer,项目名称:nan,代码行数:27,代码来源:RevokerFactoryBean.java

示例12: onChanged

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
@Override
public void onChanged(String parentPath, List<String> currentChildren) {
  if (currentChildren == null) {
    LOGGER.error("{} is null", parentPath);
    return;
  } else {
    LOGGER.warn("{} is changed to '{}'", parentPath, currentChildren);
  }

  Map<Integer, String> zkRedisCluster = new HashMap<Integer, String>();
  for (String node : currentChildren) {
    String nodeData = client.getData(String.class, parentPath + SLASH + node);
    zkRedisCluster.put(Integer.parseInt(node), nodeData);
  }

  if (MapUtils.isNotEmpty(zkRedisCluster) && !zkRedisCluster.equals(redisCluster)) {
    redisCluster = zkRedisCluster;
    if (isRedisAccessParallel) {
      redisAccess = new RedisAccessParallel(zkRedisCluster);
    } else {
      redisAccess = new RedisAccessSerial(zkRedisCluster);
    }
  }
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:25,代码来源:ZKChildMonitor.java

示例13: getBeanMap

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private Map<Object, Object> getBeanMap(Object obj) throws Exception {
    Map oMap = new BeanMap(obj);
    Map rMap = new HashMap();
    if (MapUtils.isEmpty(oMap)) {
        throw new Exception("实体类没有可用属性");
    } else {
        // 去除class属性
        for (Object key : oMap.keySet()) {
            if (!"class".equals(key)) {
                rMap.put(key, oMap.get(key));
            }
        }
    }
    return rMap;
}
 
开发者ID:phoenix-varus,项目名称:jeeWe,代码行数:17,代码来源:BaseProvider.java

示例14: createWebTarget

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
private static WebTarget createWebTarget(String uri, Map<String, String> queryParams) throws URISyntaxException
{
    WebTarget webTarget = null;

    URI u = new URI(uri);
    Client client = ClientBuilder.newClient();

    webTarget = client.target(u);

    if (MapUtils.isNotEmpty(queryParams))
    {
        for (Entry<String, String> entry : queryParams.entrySet())
        {
            if (StringUtils.isNotBlank(entry.getKey()) && StringUtils.isNotBlank(entry.getValue()))
            {
                String value = UriComponent.encode(
                        entry.getValue(),
                        UriComponent.Type.QUERY_PARAM_SPACE_ENCODED);

                webTarget = webTarget.queryParam(entry.getKey(), value);
            }
        }
    }

    return webTarget;
}
 
开发者ID:okean,项目名称:alm-rest-api,代码行数:27,代码来源:RestConnector.java

示例15: toCustomFieldValues

import org.apache.commons.collections.MapUtils; //导入依赖的package包/类
public <CFV extends CustomFieldValue> void toCustomFieldValues(final Class<CFV> valueClass, final List<? extends CustomField> allowedFields, final Map<String, String> customValues, final Collection<CFV> fieldValues) {
    if (MapUtils.isNotEmpty(customValues)) {
        for (String internalName : customValues.keySet()) {
            String value = customValues.get(internalName);
            if (StringUtils.isNotEmpty(value)) {
                CustomField field = customFieldHelper.findByInternalName(allowedFields, internalName);
                if (field == null) {
                    throw new IllegalArgumentException("Couldn't find custom field with internal name: '" + internalName + "' or the field is not searchable");
                } else {
                    CFV fieldValue;
                    try {
                        fieldValue = valueClass.newInstance();
                    } catch (Exception e) {
                        throw new IllegalStateException(e);
                    }
                    fieldValue.setField(field);
                    fieldValue.setValue(value);
                    fieldValues.add(fieldValue);
                }
            }
        }
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:24,代码来源:FieldHelper.java


注:本文中的org.apache.commons.collections.MapUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。