Ejemplo n.º 1
0
  private void parseRolloutPlans(
      XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)
      throws XMLStreamException {

    String hash = readStringAttributeElement(reader, Attribute.SHA1.getLocalName());

    ModelNode addAddress = address.clone().add(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS);
    ModelNode addOp = Util.getEmptyOperation(ADD, addAddress);
    try {
      addOp.get(HASH).set(HashUtil.hexStringToByteArray(hash));
    } catch (final Exception e) {
      throw MESSAGES.invalidSha1Value(e, hash, Attribute.SHA1.getLocalName(), reader.getLocation());
    }

    list.add(addOp);
  }
Ejemplo n.º 2
0
 private void writeManagementClientContent(XMLExtendedStreamWriter writer, ModelNode modelNode)
     throws XMLStreamException {
   boolean hasRolloutPlans =
       modelNode.hasDefined(ROLLOUT_PLANS) && modelNode.get(ROLLOUT_PLANS).hasDefined(HASH);
   boolean mustWrite = hasRolloutPlans; // || other elements we may add later
   if (mustWrite) {
     writer.writeStartElement(Element.MANAGEMENT_CLIENT_CONTENT.getLocalName());
     if (hasRolloutPlans) {
       writer.writeEmptyElement(Element.ROLLOUT_PLANS.getLocalName());
       writer.writeAttribute(
           Attribute.SHA1.getLocalName(),
           HashUtil.bytesToHexString(modelNode.get(ROLLOUT_PLANS).get(HASH).asBytes()));
     }
     writer.writeEndElement();
   }
 }