[teiid-commits] teiid SVN: r2967 - in trunk/console/src/main: java/org/teiid/rhq/plugin and 2 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Fri Mar 4 13:03:56 EST 2011
Author: tejones
Date: 2011-03-04 13:03:55 -0500 (Fri, 04 Mar 2011)
New Revision: 2967
Modified:
trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/AbstractDeployer.java
trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/RemoteDeployer.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-1217 - Added version parameter to the VDB Deploy Via URL operation as well as file deployment.
Modified: trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2011-03-04 17:34:03 UTC (rev 2966)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2011-03-04 18:03:55 UTC (rev 2967)
@@ -65,7 +65,8 @@
private static ManagedComponent mc = null;
private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static final String VDB_EXT = ".vdb"; //$NON-NLS-1$
+ public static final String VDB_EXT = ".vdb"; //$NON-NLS-1$
+ public static final String DYNAMIC_VDB_EXT = "-vdb.xml"; //$NON-NLS-1$
//Session metadata fields
private static final String SECURITY_DOMAIN = "securityDomain"; //$NON-NLS-1$
@@ -154,10 +155,8 @@
Object resultObject = new Object();
if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
- // TODO remove version parameter after AdminAPI is changed
resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
} else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
- // TODO remove version parameter after AdminAPI is changed
resultObject = getVDBStatus(connection, (String) valueMap.get(VDB.NAME));
} else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
@@ -244,15 +243,22 @@
} else if (operationName.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
String vdbUrl = (String) valueMap.get(Operation.Value.VDB_URL);
String deployName = (String) valueMap.get(Operation.Value.VDB_DEPLOY_NAME);
-
- // add vdb extension if missing
- if (!deployName.endsWith(VDB_EXT)) {
- deployName = deployName + VDB_EXT;
+ Object vdbVersion = valueMap.get(Operation.Value.VDB_VERSION);
+ //strip off vdb extension if user added it
+ if (deployName.endsWith(VDB_EXT)){
+ deployName = deployName.substring(0, deployName.lastIndexOf(VDB_EXT));
}
-
+ if (vdbVersion!=null){
+ deployName = deployName + "." + ((Integer)vdbVersion).toString() + VDB_EXT; //$NON-NLS-1$
+ }
+ //add vdb extension if there was no version
+ if (!deployName.endsWith(VDB_EXT) && !deployName.endsWith(DYNAMIC_VDB_EXT)){
+ deployName = deployName + VDB_EXT;
+ }
+
try {
URL url = new URL(vdbUrl);
- DeploymentUtils.deployArchive(deployName, connection.getDeploymentManager(), url, false);
+ DeploymentUtils.deployArchive( deployName, connection.getDeploymentManager(), url, false);
} catch (Exception e) {
final String msg = "Exception executing operation: " + Platform.Operations.DEPLOY_VDB_BY_URL; //$NON-NLS-1$
LOG.error(msg, e);
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2011-03-04 17:34:03 UTC (rev 2966)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2011-03-04 18:03:55 UTC (rev 2967)
@@ -47,6 +47,7 @@
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.content.PackageDetailsKey;
@@ -87,6 +88,7 @@
import org.teiid.rhq.plugin.util.DeploymentUtils;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+import org.teiid.rhq.plugin.util.PluginConstants.Operation;
/**
* This class implements required RHQ interfaces and provides common logic used
@@ -794,7 +796,35 @@
protected void createContentBasedResource(
CreateResourceReport createResourceReport) {
+
+ Property versionProp = createResourceReport.getPackageDetails().getDeploymentTimeConfiguration().get(Operation.Value.VDB_VERSION);
+ String name = createResourceReport.getPackageDetails().getKey().getName();
+ name = name.substring(name.lastIndexOf(File.separatorChar)+1);
+ String userSpecifiedName = createResourceReport.getUserSpecifiedResourceName();
+ String deployName = (userSpecifiedName !=null ? userSpecifiedName : name);
+
+ if (versionProp!=null){
+
+ Integer vdbVersion = ((PropertySimple)versionProp).getIntegerValue();
+ //strip off vdb extension if user added it
+ if (deployName.endsWith(DQPManagementView.VDB_EXT)){
+ deployName = deployName.substring(0, deployName.lastIndexOf(DQPManagementView.VDB_EXT));
+ }
+ if (vdbVersion!=null){
+ deployName = deployName + "." + ((Integer)vdbVersion).toString() + DQPManagementView.VDB_EXT; //$NON-NLS-1$
+ }
+ //add vdb extension if there was no version
+ if (!deployName.endsWith(DQPManagementView.VDB_EXT) && !deployName.endsWith(DQPManagementView.DYNAMIC_VDB_EXT)){
+ deployName = deployName + DQPManagementView.VDB_EXT;
+ }
+
+ //null out version
+ PropertySimple nullVersionProperty = new PropertySimple(Operation.Value.VDB_VERSION, null);
+ createResourceReport.getPackageDetails().getDeploymentTimeConfiguration().put(nullVersionProperty);
+ createResourceReport.setUserSpecifiedResourceName(deployName);
+ }
+
getDeployer().deploy(createResourceReport, createResourceReport.getResourceType());
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2011-03-04 17:34:03 UTC (rev 2966)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2011-03-04 18:03:55 UTC (rev 2967)
@@ -104,6 +104,7 @@
} else if (name.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
valueMap.put(Operation.Value.VDB_URL, configuration.getSimple(Operation.Value.VDB_URL).getStringValue());
valueMap.put(Operation.Value.VDB_DEPLOY_NAME, configuration.getSimple(Operation.Value.VDB_DEPLOY_NAME).getStringValue());
+ valueMap.put(Operation.Value.VDB_VERSION, configuration.getSimple(Operation.Value.VDB_VERSION).getIntegerValue());
}
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/AbstractDeployer.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/AbstractDeployer.java 2011-03-04 17:34:03 UTC (rev 2966)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/AbstractDeployer.java 2011-03-04 18:03:55 UTC (rev 2967)
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.resource.CreateResourceStatus;
@@ -56,9 +55,9 @@
ResourcePackageDetails details = createResourceReport.getPackageDetails();
PackageDetailsKey key = details.getKey();
- archiveFile = prepareArchive(key, resourceType);
+ archiveFile = prepareArchive(createResourceReport.getUserSpecifiedResourceName(), key, resourceType);
- String archiveName = key.getName();
+ String archiveName = archiveFile.getName();
if (!DeploymentUtils.hasCorrectExtension(archiveName, resourceType)) {
createResourceReport.setStatus(CreateResourceStatus.FAILURE);
@@ -66,11 +65,6 @@
return;
}
- // abortIfApplicationAlreadyDeployed(resourceType, archiveFile);
-
- Configuration deployTimeConfig = details.getDeploymentTimeConfiguration();
- @SuppressWarnings( { "ConstantConditions" })
-
DeploymentManager deploymentManager = this.profileServiceConnection.getDeploymentManager();
DeploymentUtils.deployArchive(deploymentManager, archiveFile, false);
@@ -102,25 +96,10 @@
protected abstract File prepareArchive(PackageDetailsKey key,
ResourceType resourceType);
+
+ protected abstract File prepareArchive(String userSpecifiedName, PackageDetailsKey key,
+ ResourceType resourceType);
protected abstract void destroyArchive(File archive);
-
- // private void abortIfApplicationAlreadyDeployed(ResourceType resourceType,
- // File archiveFile) throws Exception {
- // String archiveFileName = archiveFile.getName();
- // KnownDeploymentTypes deploymentType =
- // ConversionUtils.getDeploymentType(resourceType);
- // String deploymentTypeString = deploymentType.getType();
- // ManagementView managementView =
- // profileServiceConnection.getManagementView();
- // managementView.load();
- // Set<ManagedDeployment> managedDeployments =
- // managementView.getDeploymentsForType(deploymentTypeString);
- // for (ManagedDeployment managedDeployment : managedDeployments) {
- // if (managedDeployment.getSimpleName().equals(archiveFileName))
- // throw new IllegalArgumentException("An application named '" +
- // archiveFileName
- // + "' is already deployed.");
- // }
- // }
+
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/RemoteDeployer.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/RemoteDeployer.java 2011-03-04 17:34:03 UTC (rev 2966)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/deployer/RemoteDeployer.java 2011-03-04 18:03:55 UTC (rev 2967)
@@ -61,7 +61,7 @@
}
@Override
- protected File prepareArchive(PackageDetailsKey key, ResourceType resourceType) {
+ protected File prepareArchive(String userSpecifedName, PackageDetailsKey key, ResourceType resourceType) {
//we're running in the agent. During the development of this functionality, there was
//a time when the deployment only worked from within the JBossAS server home.
//Further investigation never confirmed the problem again but since we have access to
@@ -71,12 +71,9 @@
try {
File tempDir = createTempDirectory("teiid-deploy-content", null, getServerTempDirectory());
- File archiveFile = new File(key.getName());
+ //The userSpecifiedName is used in case we renamed the file to add version.
+ File contentCopy = new File(tempDir, userSpecifedName);
- //this is to ensure that we only get the filename part no matter whether the key contains
- //full path or not.
- File contentCopy = new File(tempDir, archiveFile.getName());
-
os = new BufferedOutputStream(new FileOutputStream(contentCopy));
ContentContext contentContext = resourceContext.getContentContext();
ContentServices contentServices = contentContext.getContentServices();
@@ -137,4 +134,11 @@
return tmpDir;
}
+
+ @Override
+ protected File prepareArchive(PackageDetailsKey key,
+ ResourceType resourceType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2011-03-04 17:34:03 UTC (rev 2966)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2011-03-04 18:03:55 UTC (rev 2967)
@@ -159,10 +159,12 @@
description="Deploy a VDB using a URL">
<parameters>
<c:simple-property displayName="VDB URL" name="vdbUrl"
- type="file" required="true" description="The URL of the VDB's source file" />
- <c:simple-property displayName="VDB Deploy File Name"
+ type="file" required="true" description="The URL of the VDB's source file." />
+ <c:simple-property displayName="VDB File Name"
name="vdbDeployName" type="string" required="true"
- description="The deployment file name to use. Must match the VDB Name you are deploying." />
+ description="The name of the VDB to deploy." />
+ <c:simple-property displayName="VDB Version" name="vdbVersion"
+ type="integer" required="false" description="The version to use for the deployed VDB. Leave blank to use the default version as determined by the deployer, overwrite a current version, or use the VDB file name version (i.e. vdbname.{version}.vdb). The version parameter is not applicable for deployment of dynamic VDBs." />
</parameters>
</operation>
@@ -560,7 +562,14 @@
<content name="vdb" displayName="VDB File" category="deployable"
isCreationType="true">
- </content>
+ <configuration>
+ <c:group name="deployment" displayName="Deployment Options">
+ <c:simple-property displayName="VDB Version" name="vdbVersion"
+ type="integer" required="false"
+ description="The version to use for the deployed VDB. Leave blank to use the default version as determined by the deployer, overwrite a current version, or use the VDB file name version (i.e. vdbname.{version}.vdb). The version parameter is not applicable for deployment of dynamic VDBs." />
+ </c:group>
+ </configuration>
+ </content>
<resource-configuration>
<c:group name="general" displayName="General"
More information about the teiid-commits
mailing list