[teiid-commits] teiid SVN: r2534 - branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Sep 7 11:48:49 EDT 2010


Author: tejones
Date: 2010-09-07 11:48:49 -0400 (Tue, 07 Sep 2010)
New Revision: 2534

Modified:
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
Log:
TEIID-1243: Re-implemented previously removed method. Also, modified logic to support multiple versions of a VDB which was previously unaccounted for. 

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java	2010-09-04 03:29:29 UTC (rev 2533)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java	2010-09-07 15:48:49 UTC (rev 2534)
@@ -21,17 +21,19 @@
  */
 package org.teiid.rhq.plugin;
 
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
+import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javax.naming.NamingException;
-
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.deployers.spi.management.ManagementView;
@@ -49,6 +51,8 @@
 import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
 import org.rhq.core.domain.content.PackageDetailsKey;
 import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.ContentResponseResult;
+import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
 import org.rhq.core.domain.content.transfer.DeployPackageStep;
 import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
 import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
@@ -72,6 +76,7 @@
 import org.rhq.core.pluginapi.measurement.MeasurementFacet;
 import org.rhq.core.pluginapi.operation.OperationFacet;
 import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.util.exception.ThrowableUtil;
 import org.rhq.plugins.jbossas5.ProfileServiceComponent;
 import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
 import org.teiid.rhq.admin.DQPManagementView;
@@ -85,11 +90,13 @@
  * This class implements required RHQ interfaces and provides common logic used
  * by all MetaMatrix components.
  */
-public abstract class Facet implements ProfileServiceComponent<ResourceComponent>, MeasurementFacet,
+public abstract class Facet implements
+		ProfileServiceComponent<ResourceComponent>, MeasurementFacet,
 		OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
 		CreateChildResourceFacet {
 
-	protected final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+	protected final Log LOG = LogFactory
+			.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
 
 	/**
 	 * Represents the resource configuration of the custom product being
@@ -113,11 +120,15 @@
 
 	private final Log log = LogFactory.getLog(this.getClass());
 
+	private File deploymentFile;
+	private static final String BACKUP_FILE_EXTENSION = ".rej"; //$NON-NLS-1$
+
 	/**
 	 * The name of the ManagedDeployment (e.g.:
 	 * C:/opt/jboss-5.0.0.GA/server/default/deploy/foo.vdb).
 	 */
 	protected String deploymentName;
+	protected String deploymentUrl;
 
 	private PackageVersions versions = null;
 
@@ -128,12 +139,12 @@
 	 * "vdb". This is still unique within the context of the parent resource
 	 * type and lets this class use the same package type name in both cases.
 	 */
-	private static final String PKG_TYPE_VDB = "vdb";
+	private static final String PKG_TYPE_VDB = "vdb"; //$NON-NLS-1$
 
 	/**
 	 * Architecture string used in describing discovered packages.
 	 */
-	private static final String ARCHITECTURE = "noarch";
+	private static final String ARCHITECTURE = "noarch"; //$NON-NLS-1$
 
 	abstract String getComponentType();
 
@@ -149,8 +160,6 @@
 		deploymentName = context.getResourceKey();
 	}
 
-	
-	
 	/**
 	 * This is called when the component is being stopped, usually due to the
 	 * plugin container shutting down. You can perform some cleanup here; though
@@ -176,7 +185,7 @@
 	public void setResourceConfiguration(Configuration resourceConfiguration) {
 		this.resourceConfiguration = resourceConfiguration;
 	}
-	
+
 	public String componentType() {
 		return name;
 	}
@@ -197,8 +206,8 @@
 			Configuration configuration, Map<String, Object> argumentMap) {
 		// moved this logic up to the associated implemented class
 		throw new InvalidPluginConfigurationException(
-				"Not implemented on component type " + this.getComponentType()
-						+ " named " + this.name);
+				"Not implemented on component type " + this.getComponentType() //$NON-NLS-1$
+						+ " named " + this.name); //$NON-NLS-1$
 
 	}
 
@@ -206,12 +215,13 @@
 			Map<String, Object> argumentMap) {
 		// moved this logic up to the associated implemented class
 		throw new InvalidPluginConfigurationException(
-				"Not implemented on component type " + this.getComponentType()
-						+ " named " + this.name);
+				"Not implemented on component type " + this.getComponentType() //$NON-NLS-1$
+						+ " named " + this.name); //$NON-NLS-1$
 
 	}
 
-	protected void execute(final ProfileServiceConnection connection, final ExecutedResult result, final Map valueMap) {
+	protected void execute(final ProfileServiceConnection connection,
+			final ExecutedResult result, final Map<String, Object> valueMap) {
 		DQPManagementView dqp = new DQPManagementView();
 
 		dqp.executeOperation(connection, result, valueMap);
@@ -262,7 +272,7 @@
 	 */
 	public OperationResult invokeOperation(String name,
 			Configuration configuration) {
-		Map valueMap = new HashMap();
+		Map<String, Object> valueMap = new HashMap<String, Object>();
 
 		Set operationDefinitionSet = this.resourceContext.getResourceType()
 				.getOperationDefinitions();
@@ -317,24 +327,27 @@
 		resourceConfiguration = report.getConfiguration().deepCopy();
 
 		Configuration resourceConfig = report.getConfiguration();
-		
-		ManagementView managementView = null; 
+
+		ManagementView managementView = null;
 		ComponentType componentType = null;
-		if (this.getComponentType().equals(PluginConstants.ComponentType.VDB.NAME)) {
+		if (this.getComponentType().equals(
+				PluginConstants.ComponentType.VDB.NAME)) {
 			componentType = new ComponentType(
 					PluginConstants.ComponentType.VDB.TYPE,
 					PluginConstants.ComponentType.VDB.SUBTYPE);
 		} else {
 			report.setStatus(ConfigurationUpdateStatus.FAILURE);
-			report.setErrorMessage("Update not implemented for the component type.");
+			report
+					.setErrorMessage("Update not implemented for the component type."); //$NON-NLS-1$
 		}
 
 		ManagedComponent managedComponent = null;
 		report.setStatus(ConfigurationUpdateStatus.SUCCESS);
 		try {
-			
+
 			managementView = getConnection().getManagementView();
-			managedComponent = managementView.getComponent(this.name, componentType);
+			managedComponent = managementView.getComponent(this.name,
+					componentType);
 			Map<String, ManagedProperty> managedProperties = managedComponent
 					.getProperties();
 
@@ -343,16 +356,16 @@
 							.getResourceType());
 
 			try {
-				managementView.updateComponent(managedComponent);				
+				managementView.updateComponent(managedComponent);
 			} catch (Exception e) {
-				LOG.error("Unable to update component ["
-						+ managedComponent.getName() + "] of type "
-						+ componentType + ".", e);
+				LOG.error("Unable to update component [" //$NON-NLS-1$
+						+ managedComponent.getName() + "] of type " //$NON-NLS-1$
+						+ componentType + ".", e); //$NON-NLS-1$
 				report.setStatus(ConfigurationUpdateStatus.FAILURE);
 				report.setErrorMessageFromThrowable(e);
 			}
 		} catch (Exception e) {
-			LOG.error("Unable to process update request", e);
+			LOG.error("Unable to process update request", e); //$NON-NLS-1$
 			report.setStatus(ConfigurationUpdateStatus.FAILURE);
 			report.setErrorMessageFromThrowable(e);
 		}
@@ -373,11 +386,11 @@
 	 */
 	protected void updateComponent(ManagedComponent managedComponent)
 			throws Exception {
-		log.trace("Updating " + this.name + " with component "
-				+ managedComponent.toString() + "...");
+		log.trace("Updating " + this.name + " with component " //$NON-NLS-1$ //$NON-NLS-2$
+				+ managedComponent.toString() + "..."); //$NON-NLS-1$
 		ManagementView managementView = getConnection().getManagementView();
 		managementView.updateComponent(managedComponent);
-		
+
 	}
 
 	@Override
@@ -386,25 +399,25 @@
 		DeploymentManager deploymentManager = getConnection()
 				.getDeploymentManager();
 
-		log.debug("Stopping deployment [" + this.deploymentName + "]...");
+		log.debug("Stopping deployment [" + this.deploymentName + "]..."); //$NON-NLS-1$ //$NON-NLS-2$
 		DeploymentProgress progress = deploymentManager
 				.stop(this.deploymentName);
 		DeploymentStatus stopStatus = DeploymentUtils.run(progress);
 		if (stopStatus.isFailed()) {
-			log.error("Failed to stop deployment '" + this.deploymentName
-					+ "'.", stopStatus.getFailure());
-			throw new Exception("Failed to stop deployment '"
-					+ this.deploymentName + "' - cause: "
+			log.error("Failed to stop deployment '" + this.deploymentName //$NON-NLS-1$
+					+ "'.", stopStatus.getFailure()); //$NON-NLS-1$
+			throw new Exception("Failed to stop deployment '" //$NON-NLS-1$
+					+ this.deploymentName + "' - cause: " //$NON-NLS-1$
 					+ stopStatus.getFailure());
 		}
-		log.debug("Removing deployment [" + this.deploymentName + "]...");
+		log.debug("Removing deployment [" + this.deploymentName + "]..."); //$NON-NLS-1$ //$NON-NLS-2$
 		progress = deploymentManager.remove(this.deploymentName);
 		DeploymentStatus removeStatus = DeploymentUtils.run(progress);
 		if (removeStatus.isFailed()) {
-			log.error("Failed to remove deployment '" + this.deploymentName
-					+ "'.", removeStatus.getFailure());
-			throw new Exception("Failed to remove deployment '"
-					+ this.deploymentName + "' - cause: "
+			log.error("Failed to remove deployment '" + this.deploymentName //$NON-NLS-1$
+					+ "'.", removeStatus.getFailure()); //$NON-NLS-1$
+			throw new Exception("Failed to remove deployment '" //$NON-NLS-1$
+					+ this.deploymentName + "' - cause: " //$NON-NLS-1$
 					+ removeStatus.getFailure());
 		}
 
@@ -414,13 +427,257 @@
 	public DeployPackagesResponse deployPackages(
 			Set<ResourcePackageDetails> packages,
 			ContentServices contentServices) {
-		return null;
+		// You can only update the one application file referenced by this
+		// resource, so punch out if multiple are
+		// specified.
+		if (packages.size() != 1) {
+			log
+					.warn("Request to update a VDB file contained multiple packages: " //$NON-NLS-1$
+							+ packages);
+			DeployPackagesResponse response = new DeployPackagesResponse(
+					ContentResponseResult.FAILURE);
+			response
+					.setOverallRequestErrorMessage("When updating a VDB, only one VDB can be updated at a time."); //$NON-NLS-1$
+			return response;
+		}
+
+		ResourcePackageDetails packageDetails = packages.iterator().next();
+
+		log.debug("Updating VDB file '" + this.deploymentFile + "' using [" //$NON-NLS-1$ //$NON-NLS-2$
+				+ packageDetails + "]..."); //$NON-NLS-1$
+
+		log.debug("Writing new VDB bits to temporary file..."); //$NON-NLS-1$
+		File tempFile;
+		try {
+			tempFile = writeNewAppBitsToTempFile(contentServices,
+					packageDetails);
+		} catch (Exception e) {
+			return failApplicationDeployment(
+					"Error writing new application bits to temporary file - cause: " //$NON-NLS-1$
+							+ e, packageDetails);
+		}
+		log.debug("Wrote new VDB bits to temporary file '" + tempFile //$NON-NLS-1$
+				+ "'."); //$NON-NLS-1$
+
+		boolean deployExploded = this.deploymentFile.isDirectory();
+
+		// Backup the original app file/dir to <filename>.rej.
+		File backupOfOriginalFile = new File(this.deploymentFile.getPath()
+				+ BACKUP_FILE_EXTENSION);
+		log.debug("Backing up existing VDB '" + this.deploymentFile //$NON-NLS-1$
+				+ "' to '" + backupOfOriginalFile + "'..."); //$NON-NLS-1$ //$NON-NLS-2$
+		try {
+			if (backupOfOriginalFile.exists())
+				FileUtils.forceDelete(backupOfOriginalFile);
+			if (this.deploymentFile.isDirectory())
+				FileUtils.copyDirectory(this.deploymentFile,
+						backupOfOriginalFile, true);
+			else
+				FileUtils.copyFile(this.deploymentFile, backupOfOriginalFile,
+						true);
+		} catch (Exception e) {
+			throw new RuntimeException("Failed to backup existing EAR/WAR '" //$NON-NLS-1$
+					+ this.deploymentFile + "' to '" + backupOfOriginalFile //$NON-NLS-1$
+					+ "'."); //$NON-NLS-1$
+		}
+
+		// Now stop the original app.
+		try {
+			DeploymentManager deploymentManager = getConnection()
+					.getDeploymentManager();
+			DeploymentProgress progress = deploymentManager
+					.stop(this.deploymentUrl);
+			DeploymentUtils.run(progress);
+		} catch (Exception e) {
+			throw new RuntimeException("Failed to stop deployment [" //$NON-NLS-1$
+					+ this.deploymentUrl + "].", e); //$NON-NLS-1$
+		}
+
+		// And then remove it (this will delete the physical file/dir from the
+		// deploy dir).
+		try {
+			DeploymentManager deploymentManager = getConnection()
+					.getDeploymentManager();
+			DeploymentProgress progress = deploymentManager
+					.remove(this.deploymentUrl);
+			DeploymentUtils.run(progress);
+		} catch (Exception e) {
+			throw new RuntimeException("Failed to remove deployment [" //$NON-NLS-1$
+					+ this.deploymentUrl + "].", e); //$NON-NLS-1$
+		}
+
+		// Deploy away!
+		log.debug("Deploying '" + tempFile + "'..."); //$NON-NLS-1$ //$NON-NLS-2$
+		DeploymentManager deploymentManager = getConnection()
+				.getDeploymentManager();
+		try {
+			DeploymentUtils.deployArchive(deploymentManager, tempFile,
+					deployExploded);
+		} catch (Exception e) {
+			// Deploy failed - rollback to the original app file...
+			log.debug("Redeploy failed - rolling back to original archive...", //$NON-NLS-1$
+					e);
+			String errorMessage = ThrowableUtil.getAllMessages(e);
+			try {
+				// Delete the new app, which failed to deploy.
+				FileUtils.forceDelete(this.deploymentFile);
+				// Need to re-deploy the original file - this generally should
+				// succeed.
+				DeploymentUtils.deployArchive(deploymentManager,
+						backupOfOriginalFile, deployExploded);
+				errorMessage += " ***** ROLLED BACK TO ORIGINAL APPLICATION FILE. *****"; //$NON-NLS-1$
+			} catch (Exception e1) {
+				log.debug("Rollback failed!", e1); //$NON-NLS-1$
+				errorMessage += " ***** FAILED TO ROLLBACK TO ORIGINAL APPLICATION FILE. *****: " //$NON-NLS-1$
+						+ ThrowableUtil.getAllMessages(e1);
+			}
+			log.info("Failed to update VDB file '" + this.deploymentFile //$NON-NLS-1$
+					+ "' using [" + packageDetails + "]."); //$NON-NLS-1$ //$NON-NLS-2$
+			return failApplicationDeployment(errorMessage, packageDetails);
+		}
+
+		// Deploy was successful!
+
+		deleteBackupOfOriginalFile(backupOfOriginalFile);
+		persistApplicationVersion(packageDetails, this.deploymentFile);
+
+		DeployPackagesResponse response = new DeployPackagesResponse(
+				ContentResponseResult.SUCCESS);
+		DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(
+				packageDetails.getKey(), ContentResponseResult.SUCCESS);
+		response.addPackageResponse(packageResponse);
+
+		log.debug("Updated VDB file '" + this.deploymentFile //$NON-NLS-1$
+				+ "' successfully - returning response [" + response + "]..."); //$NON-NLS-1$ //$NON-NLS-2$
+
+		return response;
 	}
 
+	private void deleteBackupOfOriginalFile(File backupOfOriginalFile) {
+		log.debug("Deleting backup of original file '" + backupOfOriginalFile //$NON-NLS-1$
+				+ "'..."); //$NON-NLS-1$
+		try {
+			FileUtils.forceDelete(backupOfOriginalFile);
+		} catch (Exception e) {
+			// not critical.
+			log.warn("Failed to delete backup of original file: " //$NON-NLS-1$
+					+ backupOfOriginalFile);
+		}
+	}
+	
+	private void persistApplicationVersion(ResourcePackageDetails packageDetails, File appFile)
+    {
+        String packageName = appFile.getName();
+        log.debug("Persisting application version '" + packageDetails.getVersion() + "' for package '" + packageName //$NON-NLS-1$ //$NON-NLS-2$
+                + "'"); //$NON-NLS-1$
+        PackageVersions versions = loadPackageVersions();
+        versions.putVersion(packageName, packageDetails.getVersion());
+    }
+
+	private File writeNewAppBitsToTempFile(ContentServices contentServices,
+			ResourcePackageDetails packageDetails) throws Exception {
+		File tempDir = this.resourceContext.getTemporaryDirectory();
+		File tempFile = new File(tempDir, this.deploymentFile.getName());
+
+		OutputStream tempOutputStream = null;
+		try {
+			tempOutputStream = new BufferedOutputStream(new FileOutputStream(
+					tempFile));
+			long bytesWritten = contentServices.downloadPackageBits(
+					this.resourceContext.getContentContext(), packageDetails
+							.getKey(), tempOutputStream, true);
+			log
+					.debug("Wrote " + bytesWritten + " bytes to '" + tempFile //$NON-NLS-1$ //$NON-NLS-2$
+							+ "'."); //$NON-NLS-1$
+		} catch (IOException e) {
+			log.error(
+					"Error writing updated application bits to temporary location: " //$NON-NLS-1$
+							+ tempFile, e);
+			throw e;
+		} finally {
+			if (tempOutputStream != null) {
+				try {
+					tempOutputStream.close();
+				} catch (IOException e) {
+					log.error("Error closing temporary output stream", e); //$NON-NLS-1$
+				}
+			}
+		}
+		if (!tempFile.exists()) {
+			log.error("Temporary file for application update not written to: " //$NON-NLS-1$
+					+ tempFile);
+			throw new Exception();
+		}
+		return tempFile;
+	}
+
+	/**
+	 * Creates the necessary transfer objects to report a failed application
+	 * deployment (update).
+	 * 
+	 * @param errorMessage
+	 *            reason the deploy failed
+	 * @param packageDetails
+	 *            describes the update being made
+	 * @return response populated to reflect a failure
+	 */
+	private DeployPackagesResponse failApplicationDeployment(
+			String errorMessage, ResourcePackageDetails packageDetails) {
+		DeployPackagesResponse response = new DeployPackagesResponse(
+				ContentResponseResult.FAILURE);
+
+		DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(
+				packageDetails.getKey(), ContentResponseResult.FAILURE);
+		packageResponse.setErrorMessage(errorMessage);
+
+		response.addPackageResponse(packageResponse);
+
+		return response;
+	}
+
 	@Override
 	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType arg0) {
-		// Teiid does not support the versions yet.
-		return Collections.EMPTY_SET;
+
+		// PLEASE DO NOT REMOVE THIS METHOD. IT IS REQUIRED FOR THE CONTENT TAB.
+
+		Configuration pluginConfig = this.resourceContext
+				.getPluginConfiguration();
+		this.deploymentUrl = pluginConfig.getSimple("url").getStringValue(); //$NON-NLS-1$
+
+		if (this.deploymentUrl != null) {
+			this.deploymentFile = new File(this.deploymentUrl
+					.substring(deploymentUrl.indexOf(":/") + 1)); //$NON-NLS-1$
+		}
+
+		if (!deploymentFile.exists())
+			throw new IllegalStateException("Deployment file '" //$NON-NLS-1$
+					+ this.deploymentFile + "' for " + this.getComponentType() //$NON-NLS-1$
+					+ " does not exist."); //$NON-NLS-1$
+
+		String fileName = deploymentFile.getName();
+		org.rhq.core.pluginapi.content.version.PackageVersions packageVersions = loadPackageVersions();
+		String version = packageVersions.getVersion(fileName);
+		if (version == null) {
+			// This is either the first time we've discovered this VDB, or
+			// someone purged the PC's data dir.
+			version = "1.0"; //$NON-NLS-1$
+			packageVersions.putVersion(fileName, version);
+			packageVersions.saveToDisk();
+		}
+
+		// Package name is the deployment's file name (e.g. foo.ear).
+		PackageDetailsKey key = new PackageDetailsKey(fileName, version,
+				PKG_TYPE_VDB, ARCHITECTURE);
+		ResourcePackageDetails packageDetails = new ResourcePackageDetails(key);
+		packageDetails.setFileName(fileName);
+		packageDetails.setLocation(deploymentFile.getPath());
+		if (!deploymentFile.isDirectory())
+			packageDetails.setFileSize(deploymentFile.length());
+		packageDetails.setFileCreatedDate(null);  
+		Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();
+		packages.add(packageDetails);
+
+		return packages;
 	}
 
 	@Override
@@ -459,11 +716,11 @@
 	@Override
 	public CreateResourceReport createResource(CreateResourceReport report) {
 		ResourceType resourceType = report.getResourceType();
-//		if (resourceType.getName().equals("Translators")) {
-//			createConfigurationBasedResource(report);
-//		} else {
-			createContentBasedResource(report);
-//		}
+		// if (resourceType.getName().equals("Translators")) {
+		// createConfigurationBasedResource(report);
+		// } else {
+		createContentBasedResource(report);
+		// }
 
 		return report;
 	}
@@ -481,12 +738,12 @@
 		ManagementView managementView = null;
 		;
 		managementView = getConnection().getManagementView();
-		
-		if (ProfileServiceUtil.isManagedComponent(getConnection(), resourceName,
-				componentType)) {
+
+		if (ProfileServiceUtil.isManagedComponent(getConnection(),
+				resourceName, componentType)) {
 			createResourceReport.setStatus(CreateResourceStatus.FAILURE);
-			createResourceReport.setErrorMessage("A " + resourceType.getName()
-					+ " named '" + resourceName + "' already exists.");
+			createResourceReport.setErrorMessage("A " + resourceType.getName() //$NON-NLS-1$
+					+ " named '" + resourceName + "' already exists."); //$NON-NLS-1$ //$NON-NLS-2$
 			return createResourceReport;
 		}
 
@@ -499,7 +756,6 @@
 		String templateName = templateNameProperty.getStringValue();
 
 		DeploymentTemplateInfo template;
-		Set templateNamesSet = managementView.getTemplateNames();
 		try {
 			template = managementView.getTemplate(templateName);
 			Map<String, ManagedProperty> managedProperties = template
@@ -508,26 +764,26 @@
 			ProfileServiceUtil.convertConfigurationToManagedProperties(
 					managedProperties, resourceConfig, resourceType);
 
-			LOG.debug("Applying template [" + templateName
-					+ "] to create ManagedComponent of type [" + componentType
-					+ "]...");
+			LOG.debug("Applying template [" + templateName //$NON-NLS-1$
+					+ "] to create ManagedComponent of type [" + componentType //$NON-NLS-1$
+					+ "]..."); //$NON-NLS-1$
 			try {
 				managementView.applyTemplate(resourceName, template);
 				managementView.process();
 				createResourceReport.setStatus(CreateResourceStatus.SUCCESS);
 			} catch (Exception e) {
-				LOG.error("Unable to apply template [" + templateName
-						+ "] to create ManagedComponent of type "
-						+ componentType + ".", e);
+				LOG.error("Unable to apply template [" + templateName //$NON-NLS-1$
+						+ "] to create ManagedComponent of type " //$NON-NLS-1$
+						+ componentType + ".", e); //$NON-NLS-1$
 				createResourceReport.setStatus(CreateResourceStatus.FAILURE);
 				createResourceReport.setException(e);
 			}
 		} catch (NoSuchDeploymentException e) {
-			LOG.error("Unable to find template [" + templateName + "].", e);
+			LOG.error("Unable to find template [" + templateName + "].", e); //$NON-NLS-1$ //$NON-NLS-2$
 			createResourceReport.setStatus(CreateResourceStatus.FAILURE);
 			createResourceReport.setException(e);
 		} catch (Exception e) {
-			LOG.error("Unable to process create request", e);
+			LOG.error("Unable to process create request", e); //$NON-NLS-1$
 			createResourceReport.setStatus(CreateResourceStatus.FAILURE);
 			createResourceReport.setException(e);
 		}
@@ -551,8 +807,8 @@
 					resourceContext.getResourceType())) {
 				createResourceReport.setStatus(CreateResourceStatus.FAILURE);
 				createResourceReport
-						.setErrorMessage("Incorrect extension specified on filename ["
-								+ archivePath + "]");
+						.setErrorMessage("Incorrect extension specified on filename [" //$NON-NLS-1$
+								+ archivePath + "]"); //$NON-NLS-1$
 
 			}
 
@@ -567,7 +823,7 @@
 			createResourceReport.setStatus(CreateResourceStatus.SUCCESS);
 
 		} catch (Throwable t) {
-			log.error("Error deploying application for report: "
+			log.error("Error deploying application for report: " //$NON-NLS-1$
 					+ createResourceReport, t);
 			createResourceReport.setStatus(CreateResourceStatus.FAILURE);
 			createResourceReport.setException(t);
@@ -581,15 +837,15 @@
 				.getSimple(TranslatorComponent.Config.RESOURCE_NAME);
 		if (resourceNameProp == null
 				|| resourceNameProp.getStringValue() == null)
-			throw new IllegalStateException("Property ["
+			throw new IllegalStateException("Property [" //$NON-NLS-1$
 					+ TranslatorComponent.Config.RESOURCE_NAME
-					+ "] is not defined in the default plugin configuration.");
+					+ "] is not defined in the default plugin configuration."); //$NON-NLS-1$
 		String resourceNamePropName = resourceNameProp.getStringValue();
 		PropertySimple propToUseAsResourceName = resourceConfig
 				.getSimple(resourceNamePropName);
 		if (propToUseAsResourceName == null)
-			throw new IllegalStateException("Property [" + resourceNamePropName
-					+ "] is not defined in initial Resource configuration.");
+			throw new IllegalStateException("Property [" + resourceNamePropName //$NON-NLS-1$
+					+ "] is not defined in initial Resource configuration."); //$NON-NLS-1$
 		return propToUseAsResourceName.getStringValue();
 	}
 
@@ -597,9 +853,9 @@
 		ComponentType componentType = ProfileServiceUtil
 				.getComponentType(resourceType);
 		if (componentType == null)
-			throw new IllegalStateException("Unable to map " + resourceType
-					+ " to a ComponentType.");
-		return componentType.getType() + ":" + componentType.getSubtype() + ":"
+			throw new IllegalStateException("Unable to map " + resourceType //$NON-NLS-1$
+					+ " to a ComponentType."); //$NON-NLS-1$
+		return componentType.getType() + ":" + componentType.getSubtype() + ":" //$NON-NLS-1$ //$NON-NLS-2$
 				+ resourceName;
 	}
 
@@ -615,9 +871,9 @@
 			File dataDirectoryFile = resourceContext.getDataDirectory();
 			dataDirectoryFile.mkdirs();
 			String dataDirectory = dataDirectoryFile.getAbsolutePath();
-			log.trace("Creating application versions store with plugin name ["
-					+ pluginName + "] and data directory [" + dataDirectory
-					+ "]");
+			log.trace("Creating application versions store with plugin name [" //$NON-NLS-1$
+					+ pluginName + "] and data directory [" + dataDirectory //$NON-NLS-1$
+					+ "]"); //$NON-NLS-1$
 			this.versions = new PackageVersions(pluginName, dataDirectory);
 			this.versions.loadFromDisk();
 		}



More information about the teiid-commits mailing list