Package models.data

Examples of models.data.JsonResult


      render(page, topnav, agentCommandMetadataListJsonArray
           );
    } catch (Throwable t) {

      t.printStackTrace();
      renderJSON(new JsonResult("Error occured in agentUpdateWizardAdhocs "));
    }

  }
View Full Code Here


      render(page, topnav, nodeGroupSourceMetadataListJsonArray,
          agentCommandMetadataListJsonArray);
    } catch (Throwable t) {

      t.printStackTrace();
      renderJSON(new JsonResult("Error occured in wizard"));
    }

  }
View Full Code Here

     
      render(page, topnav, agentCommandMetadataListJsonArray);
    } catch (Throwable t) {

      t.printStackTrace();
      renderJSON(new JsonResult("Error occured in singleServerWizard"));
    }
  }// end
View Full Code Here

      render(page, topnav, nodeGroupSourceMetadataListJsonArray,
          agentCommandMetadataListJsonArray);
    } catch (Throwable t) {

      t.printStackTrace();
      renderJSON(new JsonResult("Error occured in wizard"));
    }

  }
View Full Code Here

      AgentCommandProvider
          .generateUpdateSendAgentCommandToNodeGroupPredefined(
              nodeGroupType, agentCommandType);

      renderJSON(new JsonResult(
          "Successful generateUpdateSendAgentCommandToNodeGroup "
              + DateUtils.getNowDateTimeStr()));
    } catch (Throwable t) {

      error"Error occured in generateUpdateSendAgentCommandToNodeGroup: " + t.getLocalizedMessage()
View Full Code Here

      AgentCommandProvider
          .generateUpdateSendAgentCommandWithoutReplaceVarAdhocMap(
              nodeGroupType, agentCommandType);

      renderJSON(new JsonResult(nodeGroupType));
    } catch (Throwable t) {

      renderJSON(new JsonResult(
          "Error occured in generateUpdateSendAgentCommandToAdhocNodeGroup :"
              + t.getLocalizedMessage()));
    }

  }
View Full Code Here

    if (request == null || request.body == null) {
      VarUtils.printSysErrWithTimeAndOptionalReason(
          "genUpdateSendCommandWithReplaceVarMapNodeSpecificAdhocJson",
          "NULL request or request body.");

      renderJSON(new JsonResult(
          "Error occured in genUpdateSendCommandWithReplaceVarMapNodeSpecificAdhocJson"));

    }

    String supermanClientIpAddress = request.remoteAddress;

    models.utils.LogUtils.printLogNormal
         ("supermanClientIpAddress in genUpdateSendCommandWithReplaceVarMapNodeSpecificAdhocJson() is "
            + supermanClientIpAddress
            + " "
            + DateUtils.getNowDateTimeStrSdsm());

    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)
              .getNodeGroupDataMapValidForSingleCommand(
                  agentCommandType));
        } else {
          // not from log; timeStamp is only used to make log file
          // names.
          String timeStamp = null;
          String rawDataSourceType = RawDataSourceType.ADHOC_AGENT_DATA
              .toString();
          String responseText = AgentCommadProviderHelperAggregation
              .genAggregationResultTextGivenAggregationType(
                  nodeGroupType, agentCommandType, timeStamp,
                  rawDataSourceType, aggregationType);

          renderJSON(responseText);
        }
        // 20131110: END whether or not aggregate response?

      } catch (Throwable t) {

        t.printStackTrace();
        renderJSON(new JsonResult(
            "Error occured in genUpdateSendCommandWithReplaceVarMapNodeSpecificAdhocJson. Error msg:"+ t.getLocalizedMessage()));
      }

    } else {
      VarUtils.printSysErrWithTimeAndOptionalReason(
          "genUpdateSendCommandWithReplaceVarMapNodeSpecificAdhocJson",
          "NULL: postData.");

      renderJSON(new JsonResult(
          "Error occured in upgradeAgents: NULL: postData."));
    }

  }
View Full Code Here

    if (request == null || request.body == null) {
      VarUtils.printSysErrWithTimeAndOptionalReason(
          "genUpdateSendCommandWithReplaceVarMapAdhocJson",
          "NULL request or request body.");

      renderJSON(new JsonResult(
          "Error occured in genUpdateSendCommandWithReplaceVarMapAdhocJson"));

    }

    String supermanClientIpAddress = request.remoteAddress;

    models.utils.LogUtils.printLogNormal
         ("supermanClientIpAddress in genUpdateSendCommandWithReplaceVarMapAdhocJson() is "
            + supermanClientIpAddress
            + " "
            + DateUtils.getNowDateTimeStrSdsm());

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

    if (postData != null) {

      try {
        RequestCommandWithReplaceMap requestCommand = new Gson()
            .fromJson(postData, RequestCommandWithReplaceMap.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
            .generateUpdateSendAgentCommandWithReplaceVarAdhocMap(
                nodeGroupType, agentCommandType,
                requestCommand.getReplacementVarMap());

        // 20131110: START whether or not aggregate response?
        if (!willAggregateResponse) {
          renderJSON(adp.adhocAgentData.get(nodeGroupType)
              .getNodeGroupDataMapValidForSingleCommand(
                  agentCommandType));
        } else {
          // not from log; timeStamp is only used to make log file
          // names.
          String timeStamp = null;
          String rawDataSourceType = RawDataSourceType.ADHOC_AGENT_DATA
              .toString();
          String responseText = AgentCommadProviderHelperAggregation
              .genAggregationResultTextGivenAggregationType(
                  nodeGroupType, agentCommandType, timeStamp,
                  rawDataSourceType, aggregationType);

          renderJSON(responseText);
        }

        // 20131110: END whether or not aggregate response?

      } catch (Throwable t) {

        t.printStackTrace();
        renderJSON(new JsonResult(
            "Error occured in genUpdateSendCommandWithReplaceVarMapAdhocJson() with reason: "
                + t.getLocalizedMessage()));
      }

    } else {
      VarUtils.printSysErrWithTimeAndOptionalReason(
          "genUpdateSendCommandWithReplaceVarMapAdhocJson",
          "NULL: postData.");

      renderJSON(new JsonResult(
          "Error occured in upgradeAgents: NULL: postData."));
    }

  }
View Full Code Here

      AgentCommandProviderHelperInternalFlow.updateRequestContentGeneric(
          nodeGroupType, agentCommandType,
          AgentDataProvider.allAgentData,
          AgentDataProvider.nodeGroupSourceMetadatas);

      renderJSON(new JsonResult("Successful updateRequestContentGeneric "
          + DateUtils.getNowDateTimeStr()));
    } catch (Throwable t) {

      renderJSON(new JsonResult(
          "Error occured in updateRequestContentGeneric"));
    }

  }
View Full Code Here

      }
      nodeGroupType = CommandProviderSingleServerHelper
          .commandToSingleTargetServer(targetNodes,
              agentCommandType, varName, targetServerNew);

      renderJSON(new JsonResult(nodeGroupType));
    } catch (Throwable t) {
      t.printStackTrace();
      renderJSON(new JsonResult(
          "Error occured in commandToSingleTargetServer"));
    }

  }// end func
View Full Code Here

TOP

Related Classes of models.data.JsonResult

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.