Example usage for org.apache.commons.collections MapUtils getString

List of usage examples for org.apache.commons.collections MapUtils getString

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils getString.

Prototype

public static String getString(final Map map, final Object key) 

Source Link

Document

Gets a String from a Map in a null-safe manner.

Usage

From source file:com.ctrip.infosec.rule.rabbitmq.OfflineMessageSender.java

public void sendToOffline(RiskFact fact) {

    RiskEvent event = dataConvert(fact);

    //CP0001002?,???
    //??,orderType  1
    String eventPoint = fact.getEventPoint();
    String orderType = MapUtils.getString(fact.getEventBody(), "orderType");

    if ("CP0001002".equals(eventPoint) && "1".equals(orderType)) {

        template.convertAndSend(defaultRoutingKey, JSON.toJSONString(event));

    }//from  w  w w.  j  a v a 2  s .c  o m

}

From source file:com.yougou.api.interceptor.impl.AuthInterceptor.java

@Override
public Object intercept(ImplementorInvocation invocation) throws InterceptionException {
    // ?APIID?//  w ww .  j  a v a2 s. co  m
    String apiId = invocation.getImplementorProxy().getImplementorMapping().getApiId();
    String appKey = MapUtils.getString(invocation.getImplementorContext().getParameters(), "app_key");

    // API??
    if (!this.isApiEnable(apiId)) {
        businessLogger.log("auth", YOPBusinessCode.API_IS_UNABLE, "API?", appKey);
        return new InterceptionException(YOPBusinessCode.API_IS_UNABLE, "API?.");
    }

    // ?API?
    if (!this.isLicense(apiId, appKey)) {
        businessLogger.log("auth", YOPBusinessCode.API_AUTH_IS_FAILURE, "?API", appKey);
        return new InterceptionException(YOPBusinessCode.API_AUTH_IS_FAILURE, "?API.");
    }

    return invocation.invoke();
}

From source file:com.streamreduce.core.model.Metric.java

@SuppressWarnings("unchecked")
public Metric(Map<String, Object> map) {
    if (map != null) {
        setId((ObjectId) MapUtils.getObject(map, "_id"));
        setAccountId(MapUtils.getString(map, "accountId"));
        setTs(MapUtils.getLong(map, "metricTimestamp"));
        setValue(MapUtils.getLong(map, "metricValue"));
        setGranularity(MapUtils.getLong(map, "metricGranularity"));
        setAgv(MapUtils.getLong(map, "metricAVGY"));
        setAgv(MapUtils.getLong(map, "metricAVGY"));
        setStddev(MapUtils.getLong(map, "metricAVGY"));
        setDiff(MapUtils.getLong(map, "metricAVGY"));
        setMin(MapUtils.getLong(map, "metricAVGY"));
        setMax(MapUtils.getLong(map, "metricAVGY"));
        setAnomaly(MapUtils.getBoolean(map, "metricIsAnomaly"));

        Map<String, String> criteria = (Map<String, String>) map.get("metricCriteria");
        setCriteria(criteria);//from   ww  w .j  a  va  2s .c  om
    }
}

From source file:com.naver.health.column.bo.ColumnBO.java

@Procedure(description = " HOME?   prodecure")
@Params(value = {//from  w  ww .  j  ava  2 s . c o m
        @ELEMENT(name = "topCategoryCode", type = String.class, branch = BRANCH.BASE, description = "?(,)"),
        @ELEMENT(name = "categoryLevel", type = String.class, branch = BRANCH.BASE, description = "  ? level(depth)") })
public Map<String, Object> getColumnHomeInfo(Map<String, Object> params) {
    List<ColumnCategory> largeCategoryList = columnDAO.selectColumnCategoryList(
            MapUtils.getString(params, "topCategoryCode"), ColumnConstants.CATEGORY_LEVEL_LARGE);
    addRepresentContentCodeToList(largeCategoryList);

    List<List<ColumnCategory>> middleCategoryList = makeMiddleCategoryList(largeCategoryList);

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("largeCategoryList", largeCategoryList);
    resultMap.put("middleCategoryList", middleCategoryList);
    return resultMap;
}

From source file:com.navercorp.pinpoint.collector.receiver.thrift.tcp.AgentEventHandler.java

@Async("agentEventWorker")
public void handleEvent(PinpointServer pinpointServer, long eventTimestamp, AgentEventType eventType) {
    Objects.requireNonNull(pinpointServer, "pinpointServer must not be null");
    Objects.requireNonNull(eventType, "pinpointServer must not be null");

    final Map<Object, Object> channelProperties = pinpointServer.getChannelProperties();
    if (MapUtils.isEmpty(channelProperties)) {
        // It can occurs CONNECTED -> RUN_WITHOUT_HANDSHAKE -> CLOSED(UNEXPECTED_CLOSE_BY_CLIENT, ERROR_UNKNOWN)
        logger.warn("maybe not yet received the handshake data - pinpointServer:{}", pinpointServer);
        return;/*from   www  .  j  a v a2 s.c  o m*/
    }

    final String agentId = MapUtils.getString(channelProperties, HandshakePropertyType.AGENT_ID.getName());
    final long startTimestamp = MapUtils.getLong(channelProperties,
            HandshakePropertyType.START_TIMESTAMP.getName());
    final AgentEventBo agentEventBo = newAgentEventBo(agentId, startTimestamp, eventTimestamp, eventType);
    this.agentEventService.insert(agentEventBo);
}

From source file:com.navercorp.pinpoint.collector.receiver.thrift.tcp.AgentLifeCycleEventHandler.java

@Async("agentEventWorker")
public void handleLifeCycleEvent(PinpointServer pinpointServer, long eventTimestamp,
        AgentLifeCycleState agentLifeCycleState, int eventCounter) {
    Objects.requireNonNull(pinpointServer, "pinpointServer must not be null");
    Objects.requireNonNull(agentLifeCycleState, "agentLifeCycleState must not be null");
    if (eventCounter < 0) {
        throw new IllegalArgumentException("eventCounter may not be negative");
    }//from   w ww. jav a 2 s  . c  o  m
    logger.info("Handle lifecycle event - pinpointServer:{}, state:{}", pinpointServer, agentLifeCycleState);

    // TODO
    Map<Object, Object> channelProperties = pinpointServer.getChannelProperties();
    final Integer socketId = MapUtils.getInteger(channelProperties, SOCKET_ID_KEY);
    if (socketId == null) {
        logger.debug("socketId not found, agent does not support life cycle management - pinpointServer:{}",
                pinpointServer);
        return;
    }

    final String agentId = MapUtils.getString(channelProperties, HandshakePropertyType.AGENT_ID.getName());
    final long startTimestamp = MapUtils.getLong(channelProperties,
            HandshakePropertyType.START_TIMESTAMP.getName());
    final long eventIdentifier = createEventIdentifier(socketId, eventCounter);
    final AgentLifeCycleBo agentLifeCycleBo = new AgentLifeCycleBo(agentId, startTimestamp, eventTimestamp,
            eventIdentifier, agentLifeCycleState);

    agentLifeCycleService.insert(agentLifeCycleBo);
}

From source file:com.navercorp.pinpoint.collector.rpc.handler.AgentLifeCycleHandler.java

public void handleLifeCycleEvent(PinpointServer pinpointServer, long eventTimestamp,
        AgentLifeCycleState agentLifeCycleState, int eventCounter) {
    if (pinpointServer == null) {
        throw new NullPointerException("pinpointServer may not be null");
    }//from   w  w w .  j a  va2 s. c om
    if (agentLifeCycleState == null) {
        throw new NullPointerException("agentLifeCycleState may not be null");
    }
    if (eventCounter < 0) {
        throw new IllegalArgumentException("eventCounter may not be negative");
    }
    logger.info("handle lifecycle event - pinpointServer:{}, state:{}", pinpointServer, agentLifeCycleState);

    Map<Object, Object> channelProperties = pinpointServer.getChannelProperties();
    final Integer socketId = MapUtils.getInteger(channelProperties, SOCKET_ID_KEY);
    if (socketId == null) {
        logger.debug("socketId not found, agent does not support life cycle management - pinpointServer:{}",
                pinpointServer);
        return;
    }

    final String agentId = MapUtils.getString(channelProperties, HandshakePropertyType.AGENT_ID.getName());
    final long startTimestamp = MapUtils.getLong(channelProperties,
            HandshakePropertyType.START_TIMESTAMP.getName());
    final long eventIdentifier = createEventIdentifier(socketId, eventCounter);

    final AgentLifeCycleBo agentLifeCycleBo = new AgentLifeCycleBo(agentId, startTimestamp, eventTimestamp,
            eventIdentifier, agentLifeCycleState);

    this.executor.execute(new AgentLifeCycleHandlerDispatch(agentLifeCycleBo));

}

From source file:com.naver.health.column.bo.ColumnBO.java

@Procedure(description = " END   prodecure")
@Params(value = {//w w  w .  j  a  v  a  2s .  c  o  m
        @ELEMENT(name = "topCategoryCode", type = String.class, branch = BRANCH.BASE, description = "?(,)()"),
        @ELEMENT(name = "categoryCode", type = String.class, branch = BRANCH.BASE, description = "??()"),
        @ELEMENT(name = "contentCode", type = String.class, branch = BRANCH.BASE, description = "?()") })
public Map<String, Object> getColumnDetail(Map<String, Object> params) {
    String topCategoryCode = MapUtils.getString(params, "topCategoryCode");
    String categoryCode = MapUtils.getString(params, "categoryCode");
    String contentCode = MapUtils.getString(params, "contentCode");

    String largeCategoryCode = getLargeCategoryCode(categoryCode);

    List<ColumnCategory> largeCategoryList = columnDAO.selectColumnCategoryList(topCategoryCode,
            ColumnConstants.CATEGORY_LEVEL_LARGE);
    addRepresentContentCodeToList(largeCategoryList);

    List<ColumnCategory> middleCategoryList = columnDAO.selectColumnCategoryList(largeCategoryCode,
            ColumnConstants.CATEGORY_LEVEL_MIDDLE);
    addRepresentContentCodeToList(middleCategoryList);

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("content", columnDAO.selectColumnContentDetailInfo(contentCode)); // content detail
    resultMap.put("largeCategoryList", largeCategoryList); //   
    resultMap.put("middleCategoryList", middleCategoryList); //   
    resultMap.put("contentTitleList", getContentTitleList(middleCategoryList));
    return resultMap;
}

From source file:com.navercorp.pinpoint.collector.rpc.handler.AgentEventHandler.java

public void handleEvent(PinpointServer pinpointServer, long eventTimestamp, AgentEventType eventType,
        Object eventMessage) {//w ww.  jav a  2 s  .com
    if (pinpointServer == null) {
        throw new NullPointerException("pinpointServer may not be null");
    }
    if (eventType == null) {
        throw new NullPointerException("eventType may not be null");
    }

    Map<Object, Object> channelProperties = pinpointServer.getChannelProperties();

    final String agentId = MapUtils.getString(channelProperties, HandshakePropertyType.AGENT_ID.getName());
    final long startTimestamp = MapUtils.getLong(channelProperties,
            HandshakePropertyType.START_TIMESTAMP.getName());

    this.executor.execute(
            new AgentEventHandlerDispatch(agentId, startTimestamp, eventTimestamp, eventType, eventMessage));
}

From source file:com.navercorp.pinpoint.collector.service.AgentEventService.java

void handleEvent(PinpointServer pinpointServer, long eventTimestamp, AgentEventType eventType,
        Object eventMessage) {//from ww  w.ja  v a 2  s  . co  m
    Objects.requireNonNull(pinpointServer, "pinpointServer must not be null");
    Objects.requireNonNull(eventType, "pinpointServer must not be null");

    Map<Object, Object> channelProperties = pinpointServer.getChannelProperties();
    if (MapUtils.isEmpty(channelProperties)) {
        // It can occurs CONNECTED -> RUN_WITHOUT_HANDSHAKE -> CLOSED(UNEXPECTED_CLOSE_BY_CLIENT, ERROR_UNKNOWN)
        logger.warn("maybe not yet received the handshake data - pinpointServer:{}", pinpointServer);
        return;
    }

    final String agentId = MapUtils.getString(channelProperties, HandshakePropertyType.AGENT_ID.getName());
    final long startTimestamp = MapUtils.getLong(channelProperties,
            HandshakePropertyType.START_TIMESTAMP.getName());

    AgentEventBo agentEventBo = newAgentEventBo(agentId, startTimestamp, eventTimestamp, eventType);
    insertEvent(agentEventBo, eventMessage);
}