本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}