Skip to content

Commit

Permalink
TEIIDDES-3025, TEIIDDES-2880
Browse files Browse the repository at this point in the history
 * Fixed data type manager issue where it could be null in certain
situations
 * Fixed VDB issue where copies of models were being searched in the
.metadata folder or in the temporary "working-files" folder during
generate VDB.xml file.
 * Added some checks to prevent NPE's during shutdown in relational and
function plugins
  • Loading branch information
blafond committed Jun 14, 2017
1 parent 83a673a commit 922a20e
Show file tree
Hide file tree
Showing 26 changed files with 280 additions and 766 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ public static DatatypeManager getDatatypeManager( final EObject object,
}

if (defaultToWorkspaceMgr && result == null) {
result = ModelerCore.getWorkspaceDatatypeManager();
result = registry.register(DEFAULT_DATATYPE_MANAGER_KEY, ModelerCore.getWorkspaceDatatypeManager());
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void canCreateResource( final URI uri ) {
final ObjectID uuid = IDGenerator.getInstance().stringToObject(uuidString);

Resource myExistingResource = this.container.getResourceFinder().findByUUID(uuid, false);
if (myExistingResource != null) {
if (myExistingResource != null && !myExistingResource.getURI().toString().contains(".metadata")) {
final URI existingResourceUri = myExistingResource.getURI();
final Object[] params = new Object[] {URI.decode(uri.toString()),
URI.decode(existingResourceUri.toString())};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ public ModelResourceImpl( final ModelWorkspaceItem parent,
resourceSet.createResource(uri);
}
} catch (DuplicateResourceException dre) {
ModelerCore.Util.log(dre);
String message = dre.getMessage();
// Perform a check to see if this is a duplicate resource under the .metadata vdb plugin
// this can be ignored as part of the VDB XML export which can happen if models
// are not synchronized
if( !message.contains(".metadata/.plugins/org.teiid.designer.vdb/") &&
!message.contains("Unable to load the model at file:") ) {
ModelerCore.Util.log(dre);
}
} catch (ModelWorkspaceException mwe) {
ModelerCore.Util.log(mwe);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ public void addNotificationListener( ModelWorkspaceNotificationListener listener
@Override
public void removeNotificationListener( ModelWorkspaceNotificationListener listener ) {
CoreArgCheck.isNotNull(listener);
ModelWorkspaceManager.getModelWorkspaceManager().removeNotificationListener(listener);
if (!ModelWorkspaceManager.isShutDown() ) {
ModelWorkspaceManager.getModelWorkspaceManager().removeNotificationListener(listener);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class ModelWorkspaceManager implements XmiHeaderCache {
public static boolean VERBOSE = false;

public static boolean ZIP_ACCESS_VERBOSE = false;

public static boolean isShutDown = true;

/**
* The singleton manager
Expand Down Expand Up @@ -175,9 +177,15 @@ public final static ModelWorkspaceManager getModelWorkspaceManager() {
ModelerCore.Util.log(IStatus.ERROR,
ModelerCore.Util.getString("ModelWorkspaceManager.Error_encountered_starting_ModelWorkspaceManager_1")); //$NON-NLS-1$
}

isShutDown = false;
}
return manager;
}

public final static boolean isShutDown() {
return isShutDown;
}

public final static void shutdown() throws CoreException {
if (manager != null) try {
Expand All @@ -198,6 +206,7 @@ public final static void shutdown() throws CoreException {
1,
ModelerCore.Util.getString("ModelWorkspaceManager.Error_encountered_shutting_down_ModelWorkspaceManager_2"), t)); //$NON-NLS-1$
} finally {
isShutDown = true;
manager = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class Messages extends NLS {
public static String GenerateVdbWizard_validation_targetLocationNotExist;
public static String GenerateVdbWizard_validation_targetFileAlreadyExists;

public static String GenerateDynamicVdbWizard_title;
public static String GenerateDynamicVdbWizard_validation_vdbMissingXmlExtension;
public static String GenerateDynamicVdbWizard_validation_noDynamicVdbGenerated;
public static String GenerateDynamicVdbWizard_exportLocationAlreadyExists;
public static String GenerateDynamicVdbWizard_exportLocationFailedToCreateFile;
public static String GenerateDynamicVdbManager_title;
public static String GenerateDynamicVdbManager_validation_vdbMissingXmlExtension;
public static String GenerateDynamicVdbManager_validation_noDynamicVdbGenerated;
public static String GenerateDynamicVdbManager_exportLocationAlreadyExists;
public static String GenerateDynamicVdbManager_exportLocationFailedToCreateFile;

public static String GenerateDynamicVdbPageOne_title;
public static String GenerateDynamicVdbPageOne_summaryGroupName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,23 @@

import java.util.Iterator;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.ui.Messages;
import org.teiid.designer.runtime.ui.DqpUiConstants.Images;
import org.teiid.designer.runtime.ui.wizards.vdbs.GenerateDynamicVdbDialog;
import org.teiid.designer.runtime.ui.wizards.vdbs.GenerateDynamicVdbManager;
import org.teiid.designer.runtime.ui.wizards.vdbs.GenerateDynamicVdbWizard;
import org.teiid.designer.ui.actions.SortableSelectionAction;
import org.teiid.designer.ui.common.actions.ModelActionConstants;
import org.teiid.designer.ui.common.eventsupport.SelectionUtilities;
import org.teiid.designer.ui.viewsupport.ModelUtilities;
import org.teiid.designer.vdb.ui.VdbUiPlugin;

public class GenerateDynamicVdbAction extends SortableSelectionAction implements DqpUiConstants {
private static final String label = DqpUiConstants.UTIL.getString("label"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ GenerateVdbWizard_validation_vdbFileNameUndefined=New VDB file name is undefined
GenerateVdbWizard_validation_targetLocationNotExist=VDB destination location does not exist
GenerateVdbWizard_validation_targetFileAlreadyExists=VDB file already exists at chosen VDB destination

GenerateDynamicVdbWizard_title=Generate Dynamic VDB
GenerateDynamicVdbWizard_validation_vdbMissingXmlExtension=Dynamic VDB file name must end with -vdb.xml
GenerateDynamicVdbWizard_validation_noDynamicVdbGenerated=A dynamic VDB has not been generated
GenerateDynamicVdbManager_title=Generate Dynamic VDB
GenerateDynamicVdbManager_validation_vdbMissingXmlExtension=Dynamic VDB file name must end with -vdb.xml
GenerateDynamicVdbManager_validation_noDynamicVdbGenerated=A dynamic VDB has not been generated

GenerateDynamicVdbWizard_exportLocationAlreadyExists=A file named {0} already exists in the directory {1}
GenerateDynamicVdbWizard_exportLocationFailedToCreateFile=Failed to create the export location for the Dynamic VDB
GenerateDynamicVdbManager_exportLocationAlreadyExists=A file named {0} already exists in the directory {1}
GenerateDynamicVdbManager_exportLocationFailedToCreateFile=Failed to create the export location for the Dynamic VDB

GenerateDynamicVdbPageOne_title=Archive VDB Information
GenerateDynamicVdbPageOne_summaryGroupName=Selected VDB Archive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,8 @@ public void run() {

}
} catch (Exception e) {
if(! e.getMessage().contains(TeiidParentServerListener.JBAS013493_CODE)) {
if(! e.getMessage().contains(TeiidParentServerListener.JBAS013493_CODE) &&
! e.getMessage().contains(TeiidParentServerListener.JBAS012174_CODE) ) {
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void setXmlFileContents(String xmlFileContents) {

private void checkDynamicVdbGenerated() throws Exception {
if (isGenerateRequired())
throw new Exception(Messages.GenerateDynamicVdbWizard_validation_noDynamicVdbGenerated);
throw new Exception(Messages.GenerateDynamicVdbManager_validation_noDynamicVdbGenerated);
}

/**
Expand Down Expand Up @@ -220,13 +220,13 @@ public void export(String directory) throws Exception {
if (!export.delete())
throw new Exception(VdbPlugin.UTIL.getString("unableToDelete", export)); //$NON-NLS-1$
}
throw new Exception(NLS.bind(Messages.GenerateDynamicVdbWizard_exportLocationAlreadyExists,
throw new Exception(NLS.bind(Messages.GenerateDynamicVdbManager_exportLocationAlreadyExists,
getOutputVdbFileName(),
directory));
}

if (!export.createNewFile())
throw new Exception(NLS.bind(Messages.GenerateDynamicVdbWizard_exportLocationFailedToCreateFile,
throw new Exception(NLS.bind(Messages.GenerateDynamicVdbManager_exportLocationFailedToCreateFile,
getOutputVdbFileName(),
directory));

Expand Down Expand Up @@ -304,12 +304,12 @@ public void validate() {
return;

if (!getOutputVdbFileName().toLowerCase().endsWith(ITeiidVdb.DYNAMIC_VDB_SUFFIX)) {
setStatus(new Status(IStatus.ERROR, PLUGIN_ID, Messages.GenerateDynamicVdbWizard_validation_vdbMissingXmlExtension));
setStatus(new Status(IStatus.ERROR, PLUGIN_ID, Messages.GenerateDynamicVdbManager_validation_vdbMissingXmlExtension));
return;
}

if (!isGenerateRequired() && getDynamicVdb() == null) {
setStatus(new Status(IStatus.ERROR, PLUGIN_ID, Messages.GenerateDynamicVdbWizard_validation_noDynamicVdbGenerated));
setStatus(new Status(IStatus.ERROR, PLUGIN_ID, Messages.GenerateDynamicVdbManager_validation_noDynamicVdbGenerated));
return;
}

Expand Down Expand Up @@ -471,7 +471,7 @@ private void saveToFileSystem(final String xml, final String fileSystemFolderUrl
throw new Exception(VdbPlugin.UTIL.getString("unableToDelete", export)); //$NON-NLS-1$
}
} else {
throw new Exception(NLS.bind(Messages.GenerateDynamicVdbWizard_exportLocationAlreadyExists,
throw new Exception(NLS.bind(Messages.GenerateDynamicVdbManager_exportLocationAlreadyExists,
getOutputVdbFileName(),
fileSystemFolderUrl));
}
Expand Down

0 comments on commit 922a20e

Please sign in to comment.