Search in sources :

Example 1 with PatchElementImpl

use of org.jboss.as.patching.metadata.impl.PatchElementImpl in project wildfly-core by wildfly.

the class IdentityPatchContext method createPatchElement.

/**
 * Copy a patch element
 *
 * @param entry         the patch entry
 * @param patchId       the patch id for the element
 * @param modifications the element modifications
 * @return the new patch element
 */
protected static PatchElement createPatchElement(final PatchEntry entry, String patchId, final List<ContentModification> modifications) {
    final PatchElement patchElement = entry.element;
    final PatchElementImpl element = new PatchElementImpl(patchId);
    element.setProvider(patchElement.getProvider());
    // Add all the rollback actions
    element.getModifications().addAll(modifications);
    element.setDescription(patchElement.getDescription());
    return element;
}
Also used : PatchElementImpl(org.jboss.as.patching.metadata.impl.PatchElementImpl) PatchElement(org.jboss.as.patching.metadata.PatchElement)

Example 2 with PatchElementImpl

use of org.jboss.as.patching.metadata.impl.PatchElementImpl in project wildfly-core by wildfly.

the class PatchXmlUtils method parseElement.

static void parseElement(final XMLExtendedStreamReader reader, final PatchBuilder builder) throws XMLStreamException {
    String id = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        if (Attribute.ID == attribute) {
            id = value;
        } else {
            throw unexpectedAttribute(reader, i);
        }
    }
    final PatchElementImpl patchElement = new PatchElementImpl(id);
    try {
        builder.addElement(patchElement);
    } catch (IllegalStateException e) {
        throw new XMLStreamException(e);
    }
    final List<ContentModification> modifications = patchElement.getModifications();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case DESCRIPTION:
                patchElement.setDescription(reader.getElementText());
                break;
            case UPGRADE:
                parseElementProvider(reader, patchElement, Patch.PatchType.CUMULATIVE);
                break;
            case NO_UPGRADE:
                parseElementProvider(reader, patchElement, Patch.PatchType.ONE_OFF);
                break;
            case MODULES:
                parseModules(reader, modifications);
                break;
            case BUNDLES:
                parseBundles(reader, modifications);
                break;
            case MISC_FILES:
                parseMiscFiles(reader, modifications);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.readStringAttributeElement(org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) PatchElementImpl(org.jboss.as.patching.metadata.impl.PatchElementImpl) HashUtils.bytesToHexString(org.jboss.as.patching.HashUtils.bytesToHexString)

Aggregations

PatchElementImpl (org.jboss.as.patching.metadata.impl.PatchElementImpl)2 XMLStreamException (javax.xml.stream.XMLStreamException)1 ParseUtils.readStringAttributeElement (org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement)1 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)1 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)1 HashUtils.bytesToHexString (org.jboss.as.patching.HashUtils.bytesToHexString)1 PatchElement (org.jboss.as.patching.metadata.PatchElement)1