Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #228 from burmanm/bz1313863
Browse files Browse the repository at this point in the history
[BZ 1313863] Add support for patching of EAP7 instances
  • Loading branch information
burmanm committed Mar 29, 2016
2 parents 48607a4 + db260b1 commit a4caa58
Show file tree
Hide file tree
Showing 13 changed files with 467 additions and 52 deletions.
Expand Up @@ -44,6 +44,7 @@ public String toString() {
private final String id;
private final Type type;
private final String identityName;
private final PatchProductType productType;
private final String targetVersion;
private final String description;
private final String contents;
Expand All @@ -52,6 +53,7 @@ public Patch(String id, Type type, String identityName, String targetVersion, St
this.id = id;
this.type = type;
this.identityName = identityName;
this.productType = PatchProductType.getValueByProductName(identityName);
this.targetVersion = targetVersion;
this.description = description;
this.contents = contents;
Expand Down Expand Up @@ -81,6 +83,10 @@ public String getContents() {
return contents;
}

public PatchProductType getProductType() {
return productType;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Expand Up @@ -27,6 +27,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand All @@ -44,7 +46,8 @@
*/
public final class PatchParser {
private static final String PATCHES_NAMESPACE_URI = "urn:jboss:patch:bundle:1.0";
private static final String PATCH_NAMESPACE_URI = "urn:jboss:patch:1.0";
private static final String PATCH_NAMESPACE_URI_REGEXP = "urn:jboss:patch:1[.][012]";
private static final Pattern NAMESPACE_PATTERN = Pattern.compile(PATCH_NAMESPACE_URI_REGEXP);

private PatchParser() {

Expand Down Expand Up @@ -190,16 +193,15 @@ private static Patch parsePatchXml(InputStream patchXmlStream, boolean captureCo
continue;
}

QName name = rdr.getName();
if (!foundPatch) {
if (foundElements) {
throw new IllegalArgumentException("Not a Wildfly patch");
}
String namespace = rdr.getName().getNamespaceURI();
foundPatch = PATCH_NAMESPACE_URI.equals(namespace) && "patch".equals(rdr.getName().getLocalPart());
foundPatch = NAMESPACE_PATTERN.matcher(name.getNamespaceURI()).matches() && "patch".equals(name.getLocalPart());
patchId = getAttributeValue(rdr, "", "id");
} else {
QName name = rdr.getName();
if (PATCH_NAMESPACE_URI.equals(name.getNamespaceURI())) {
if (NAMESPACE_PATTERN.matcher(name.getNamespaceURI()).matches()) {
if ("upgrade".equals(name.getLocalPart())) {
patchType = Patch.Type.CUMULATIVE;
identityName = getAttributeValue(rdr, "", "name");
Expand Down
@@ -0,0 +1,66 @@
/*
* RHQ Management Platform
* Copyright (C) 2005-2016 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.common.wildfly;

/**
* Simplified and combined version of JBossProductType as defined in the jboss-as-7 and wfly-10 agent plugins
*
* @author Michael Burman
*/
public enum PatchProductType {

EAP("EAP", "JBoss EAP 6", "JBoss Enterprise Application Platform 6", "EAP"),
EAP7("EAP", "EAP 7", "JBoss Enterprise Application Platform 7", "JBoss EAP"),
ISPN("ISPN", "Infinispan Server", "Infinispan Server", "Infinispan Server"),
JDG("JDG", "JBoss JDG 6", "JBoss Data Grid 6", "Data Grid"),
JPP("JPP", "JBoss JPP 6", "JBoss Portal Platform 6", "Portal Platform"),
SOA("SOA-P", "JBoss SOA-P 6", "Red Hat JBoss Fuse Service Works", "Red Hat JBoss Fuse Service Works"),
BRMS("BRMS", "JBoss BRMS", "Red Hat JBoss BRMS", "BRMS"),
BPMS("BPM Suite", "JBoss BPM Suite", "Red Hat JBoss BPM Suite", "BPM Suite"),
JDV("JDV", "Data Virt", "Red Hat JBoss Data Virtualization", "Red Hat JBoss Data Virtualization"),
WILDFLY10("WildFly", "WildFly 10", "WildFly Application Server 10", "WildFly Full");

public final String SHORT_NAME;
public final String NAME;
public final String FULL_NAME;
/** The value the server returns for the "product-name" attribute of the root resource. */
public final String PRODUCT_NAME;

PatchProductType(String shortName, String name, String fullName, String productName) {
this.SHORT_NAME = shortName;
this.NAME = name;
this.FULL_NAME = fullName;
this.PRODUCT_NAME = productName;
}

public static PatchProductType getValueByProductName(String productName) {
for (PatchProductType productType : PatchProductType.values()) {
if (productType.PRODUCT_NAME.equals(productName)) {
return productType;
}
}
return null;
}

@Override
public String toString() {
return this.NAME;
}

}
1 change: 1 addition & 0 deletions modules/enterprise/server/plugins/pom.xml
Expand Up @@ -72,6 +72,7 @@
<module>validate-all-serverplugins</module>
<module>packagetype-cli</module>
<module>wfly-patch-bundle</module>
<module>wfly-10-patch-bundle</module>
</modules>

</project>
137 changes: 137 additions & 0 deletions modules/enterprise/server/plugins/wfly-10-patch-bundle/pom.xml
@@ -0,0 +1,137 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<version>4.14.0-SNAPSHOT</version>
</parent>

<artifactId>rhq-serverplugin-wfly-10-patch-bundle</artifactId>
<packaging>jar</packaging>

<name>RHQ Wildfly 10 Patch Bundle Server Plugin</name>
<description>Server side plugin that manages Wildfly 10 patch files and exposes them as RHQ bundles</description>

<dependencies>
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-wfly-patch-parser</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
</configuration>
</plugin>

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-rhq-plugins</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>

<artifactItem>
<groupId>org.rhq</groupId>
<artifactId>rhq-wfly-patch-parser</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>

<profile>
<id>dev</id>

<properties>
<rhq.rootDir>../../../../..</rhq.rootDir>
<rhq.containerDir>${rhq.rootDir}/${rhq.devContainerServerPath}</rhq.containerDir>
<rhq.deploymentDir>${rhq.containerDir}/${rhq.serverPluginDir}</rhq.deploymentDir>
</properties>

<build>
<plugins>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>

<execution>
<id>deploy</id>
<phase>compile</phase>
<configuration>
<target>
<mkdir dir="${rhq.deploymentDir}" />
<property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
<echo>*** Updating ${deployment.file}...</echo>
<jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>

<execution>
<id>undeploy</id>
<phase>clean</phase>
<configuration>
<target>
<property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
<echo>*** Deleting ${deployment.file}...</echo>
<delete file="${deployment.file}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>

<execution>
<id>deploy-jar-meta-inf</id>
<phase>package</phase>
<configuration>
<target>
<property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
<echo>*** Updating META-INF dir in ${deployment.file}...</echo>
<unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
<patternset>
<include name="META-INF/**" />
</patternset>
</unjar>
<jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
</jar>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit a4caa58

Please sign in to comment.