Exemplo n.º 1
0
  public static String getGlobalStateDefinitionsXML(JmxAgentUser jmxAgentUser) {

    String globalStateDefinitionsXML = null;
    // SWAgent agent = convertToSwAgent(jmxUser.getSwAgentXML());
    // SWAgent swAgent =
    // TlosSpaceWide.getSpaceWideRegistry().getHeartBeatListenerRef().getSwAgentsCache().get(agent.getIpAddress()+"."+agent.getJmxPort());
    SWAgent swAgent =
        TlosSpaceWide.getSpaceWideRegistry()
            .getAgentManagerReference()
            .getSwAgentsCache()
            .get(jmxAgentUser.getAgentId() + "");
    GlobalStateDefinition globalStateDefinition = GlobalStateDefinition.Factory.newInstance();
    globalStateDefinition =
        copyGlobalStateDefinitionsXML(
            TlosSpaceWide.getSpaceWideRegistry().getGlobalStateDefinition());

    for (State state : globalStateDefinition.getGlobalStateArray()) {
      for (Substate substate : state.getSubstateArray()) {
        for (Status status : substate.getSubStateStatusesArray()) {
          for (ReturnCodeList returnCodeList : status.getReturnCodeListArray()) {

            if (!returnCodeList.getOsType().equals(swAgent.getOsType())) {
              XmlCursor xmlCursor = returnCodeList.newCursor();
              xmlCursor.removeXml();
            }
          }
        }
      }
    }

    globalStateDefinitionsXML = getGlobalStateDefinitionsXML(globalStateDefinition);

    return globalStateDefinitionsXML;
  }
Exemplo n.º 2
0
  public static String getGlobalStateDefinitionsXML(GlobalStateDefinition globalStateDefinition) {
    QName qName = GlobalStateDefinition.type.getOuterType().getDocumentElementName();
    XmlOptions xmlOptions = XMLNameSpaceTransformer.transformXML(qName);
    String globalStateDefinitionXML = globalStateDefinition.xmlText(xmlOptions);

    return globalStateDefinitionXML;
  }