Skip to content

Commit

Permalink
TEIIDDES-2242 Added check to warn user on deploying an 8.x VDB to an
Browse files Browse the repository at this point in the history
7.7.x Server and allow cancelling deploy action
  • Loading branch information
blafond committed Jul 11, 2014
1 parent c48cbea commit b744beb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

import static org.teiid.designer.runtime.ui.DqpUiConstants.PLUGIN_ID;
import static org.teiid.designer.runtime.ui.DqpUiConstants.UTIL;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -37,12 +39,14 @@
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.ui.connection.CreateVdbDataSourceAction;
import org.teiid.designer.runtime.ui.vdb.DeployVdbDialog;
import org.teiid.designer.runtime.ui.vdb.VdbAgeChecker;
import org.teiid.designer.runtime.ui.vdb.VdbDeployer;
import org.teiid.designer.runtime.ui.vdb.VdbRequiresSaveChecker;
import org.teiid.designer.ui.actions.ISelectionAction;
import org.teiid.designer.ui.common.eventsupport.SelectionUtilities;
import org.teiid.designer.ui.common.util.UiUtil;
import org.teiid.designer.vdb.Vdb;
import org.teiid.designer.vdb.VdbUtil;


/**
Expand Down Expand Up @@ -135,6 +139,11 @@ public void run() {

for (IFile nextVDB : this.selectedVDBs) {
boolean doDeploy = VdbRequiresSaveChecker.insureOpenVdbSaved(nextVDB);

if( doDeploy ) {
doDeploy = VdbAgeChecker.doDeploy(nextVDB, teiidServer.getServerVersion());
}

if (doDeploy) {
boolean deploySuccess = deployVdb(teiidServer, nextVDB);

Expand Down Expand Up @@ -289,6 +298,8 @@ public static boolean deployVdb(ITeiidServer teiidServer, final Object vdbOrVdbF
if (!MessageDialog.openQuestion(shell,title,msg)) return false;
}

if( !VdbAgeChecker.doDeploy(vdb.getFile(), teiidServer.getServerVersion()) ) return false;

final VdbDeployer deployer = new VdbDeployer(shell, vdb, teiidServer, doCreateDataSource);
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ VdbNotSyncdDialog.msg = The VDB is not Synchronized with the workspace. Do you

VdbRequiresSaveChecker.unsavedVdb.title=Save VDB
VdbRequiresSaveChecker.unsavedVdb.message=The {0} VDB has been modified and must be saved prior to deployment.\n\nSelect OK to save and continue or Cancel?

VdbAgeChecker.oldVdb.title=Deploy VDB
VdbAgeChecker.oldVdb.message=The {0} VDB was created to target an 8.x Teiid runtime and should not be deployed to an older Teiid runtime (pre-8.0 release). \
Continuing to deploy may result in your VDB being unusable on your server.\
\n\nDo you wish to deploy the VDB anyway?
#########################################
# CreateDataSourceWizard
#########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.teiid.designer.runtime.ui.vdb;

import java.util.Properties;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.datatools.connectivity.IConnectionProfile;
Expand Down Expand Up @@ -91,7 +92,8 @@ void internalRun(final IFile selectedVdb) {
try {
if (teiidServer != null) {
IStatus connectStatus = teiidServer.ping();
if (connectStatus.isOK()) {
if (connectStatus.isOK() ) {
if( !VdbAgeChecker.doDeploy(selectedVdb, teiidServer.getServerVersion())) return;
// Deploy the VDB
deployed = DeployVdbAction.deployVdb(teiidServer, selectedVdb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
Expand All @@ -53,7 +55,9 @@
import org.teiid.designer.core.workspace.ModelUtil;
import org.teiid.designer.core.workspace.WorkspaceResourceFinderUtil;
import org.teiid.designer.metamodels.core.ModelType;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.vdb.Vdb.Xml;
import org.teiid.designer.vdb.manifest.DataRoleElement;
import org.teiid.designer.vdb.manifest.ModelElement;
import org.teiid.designer.vdb.manifest.ProblemElement;
import org.teiid.designer.vdb.manifest.PropertyElement;
Expand Down Expand Up @@ -238,6 +242,28 @@ public static int getVdbVersion( final IFile file ) {
return 0;
}

/**
* Simple method that peeks inside a VDB manifest to check if the VDB was built with Teiid 8.0 or greater
* The vdb version property value was added in Teiid Designer 8.2. So it's relatively safe to do this check.
*
* @param file
* @return vdb is based on Teiid 7
*/
public static boolean isVdbTeiidVersion8orGreater( final IFile file) {
if (file.exists()) {
VdbElement manifest = VdbUtil.getVdbManifest(file);
if (manifest != null) {
for( PropertyElement pElement : manifest.getProperties()) {
if( Vdb.Xml.VALIDATION_VERSION.equalsIgnoreCase(pElement.getName())) {
return true;
}
}
}
}

return false;
}

/**
* @param modelElement the vdb model element
* @return the uuid string. may be null
Expand Down

0 comments on commit b744beb

Please sign in to comment.