Package models.rest.beans.requests

Examples of models.rest.beans.requests.RequestCommandWithNodeSpecficReplaceMap


    String postData = MyHttpUtils.readHttpRequestPostData(request.body);

    if (postData != null) {

      try {
        RequestCommandWithNodeSpecficReplaceMap requestCommand = new Gson()
            .fromJson(postData,
                RequestCommandWithNodeSpecficReplaceMap.class);
        int reducedNodeCount = AgentUtils
            .removeDuplicateNodeList(requestCommand
                .getTargetNodes());

        models.utils.LogUtils.printLogNormal("reducedNodeCount for duplicated nodes "
            + reducedNodeCount);

        AgentDataProvider adp = AgentDataProvider.getInstance();

        // this nodeGroupType has the timestamp.
        String nodeGroupType = NodeGroupProvider
            .generateAdhocNodeGroupHelper(requestCommand
                .getTargetNodes());

        // 20131026: START update to check if to add and use new adhoc
        // command?
        Boolean useNewAgentCommand = (requestCommand
            .getUseNewAgentCommand() == null) ? false
            : requestCommand.getUseNewAgentCommand();

        String agentCommandType = null;

        if (useNewAgentCommand) {
          String commandLine = requestCommand
              .getNewAgentCommandLine();
          String requestContentTemplate = requestCommand
              .getNewAgentCommandContentTemplate();
          // now to add update into memory hashmap
          agentCommandType = AgentConfigProviderHelper
              .addOrUpdateAgentCommandInMemoryFromString(
                  commandLine, requestContentTemplate);
        } else {
          agentCommandType = requestCommand.getAgentCommandType();
        }

        // 20131026: END update to check if to add and use new adhoc
        // command?

        // 20131110: START update to check if need to aggregate
        // responses; if yes: check if needs to create a new reg exp.
        // Use which regular expression
        Boolean willAggregateResponse = (requestCommand
            .getWillAggregateResponse() == null) ? false
            : requestCommand.getWillAggregateResponse();

        Boolean useNewAggregation = (requestCommand
            .getUseNewAggregation() == null) ? false
            : requestCommand.getUseNewAggregation();
        String aggregationType = null;

        if (willAggregateResponse) {
          aggregationType = requestCommand.getAggregationType();
        }
        // only when need to aggregate, and also use new expression.

        if (willAggregateResponse && useNewAggregation) {

          String aggregationExpression = requestCommand
              .getNewAggregationExpression();
          /**
           * Assumption: the aggregationExpression is encoded by URL
           * encoder http://meyerweb.com/eric/tools/dencoder/;
           *
           * Therefore; need to decode
           * http://stackoverflow.com/questions
           * /6138127/how-to-do-url-decoding-in-java
           *
           * String result = URLDecoder.decode(url, "UTF-8");
           *
           * e.g. get agent version: origin:
           * .*"Version"[:,]\s"(.*?)".* after encoder:
           * .*%22Version%22%5B%3A%2C%5D%5Cs%22(.*%3F)%22.*
           *
           * PATTERN_AGENT_VERSION_FROM_AGENT_VI now to process and
           * decode.
           */

          String aggregationExpressionAfterDecode = URLDecoder
              .decode(aggregationExpression, "UTF-8");
          // now to add update into memory hashmap
          AgentConfigProviderHelper
              .addOrUpdateAggregationMetadataInMemoryFromString(
                  aggregationType,
                  aggregationExpressionAfterDecode);
        }

        // validate: now in memory aggregationMetadatas should have this
        // entry: aggregationType
        if (willAggregateResponse
            && adp.aggregationMetadatas.get(aggregationType) == null) {
          String errorMsg = "ERROR. aggregationType "
              + aggregationType
              + " does not exist in aggregationMetadatas";

          renderJSON(new JsonResult(errorMsg));

        }

        // 20131110: END update to check if need to aggregate responses;
        // if yes: check if needs to create a new reg exp.
        // Use which regular expression

        AgentCommandProvider
            .generateUpdateSendAgentCommandWithReplaceVarMapNodeSpecificAdhoc(
                nodeGroupType, agentCommandType, requestCommand
                    .getReplacementVarMapNodeSpecific());

        // 20131110: START whether or not aggregate response?
        if (!willAggregateResponse) {
          renderJSON(adp.adhocAgentData.get(nodeGroupType)
View Full Code Here

TOP

Related Classes of models.rest.beans.requests.RequestCommandWithNodeSpecficReplaceMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.