Skip to content

Commit

Permalink
TEIIDDES-3097 (cntd) - Common JNDI name validation
Browse files Browse the repository at this point in the history
 * fixed JDBG 6 profile wizard and edit properties panel
 * fixed LDAP importer
 * fixed Salesforce importer
  • Loading branch information
blafond committed Dec 14, 2017
1 parent 106c74a commit 321d047
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public void handleEvent( Event event ) {

if (event.widget == jndiText) {
Properties properties = ((NewConnectionProfileWizard)getWizard()).getProfileProperties();
String jndiName = JndiUtil.addJavaPrefix(jndiText.getText());
String jndiName = jndiText.getText();
properties.setProperty(IJBossDsProfileConstants.JNDI_PROP_ID, jndiName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected void createCustomContents(Composite parent) {

@Override
public void modifyText(ModifyEvent e) {
String jndiName = JndiUtil.addJavaPrefix(jndiText.getText());
String jndiName = jndiText.getText();
setProperty(IJBossDsProfileConstants.JNDI_PROP_ID, jndiName);
}
});
Expand Down Expand Up @@ -498,6 +498,7 @@ void updateState() {
setErrorMessage(msg); //$NON-NLS-1$
setPingButtonEnabled(false);
setValid(false);
return;
}

if( remoteServerListRB.getSelection() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ protected IStatus run(IProgressMonitor monitor) {
}
// Check JNDI name


IStatus modelStatus = sourceModelPanel.getModelStatus();

if (sourceModelPanel.sourceModelExists()) {
if (!sourceModelPanel.sourceModelHasConnectionProfile()) {
WizardUtil.setPageComplete(this, getString("statusExistingSourceModelHasNoProfile", importManager.getSourceModelName()), IMessageProvider.ERROR); //$NON-NLS-1$
Expand All @@ -493,10 +494,18 @@ protected IStatus run(IProgressMonitor monitor) {
WizardUtil.setPageComplete(this, getString("statusExistingSourceModelHasWrongProfile", importManager.getSourceModelName()), IMessageProvider.ERROR); //$NON-NLS-1$
return;
}
} else if( modelStatus.getSeverity() == IStatus.ERROR ) {
WizardUtil.setPageComplete(this, modelStatus.getMessage(), IMessageProvider.ERROR); //$NON-NLS-1$
return;
} else {
WizardUtil.setPageComplete(this, getString("statusSourceModelDoesNotExistAndWillBeCreated", importManager.getSourceModelName()), IMessageProvider.INFORMATION); //$NON-NLS-1$
return;
}


if( modelStatus.getSeverity() == IStatus.ERROR ) {
WizardUtil.setPageComplete(this, modelStatus.getMessage(), IMessageProvider.ERROR); //$NON-NLS-1$
}

WizardUtil.setPageComplete(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
Expand Down Expand Up @@ -73,6 +74,8 @@ public class SourceModelPanel implements IChangeListener, ModelGeneratorLdapUiCo
private final ModelWorkspaceManager modelWorkspaceManager = ModelWorkspaceManager.getModelWorkspaceManager();

private boolean refreshing = false;

private IStatus sourceStatus;

/**
* Create new instance
Expand All @@ -97,6 +100,8 @@ private void init(Composite parent) {

this.connectionInfoHelper = new ConnectionInfoHelper();
this.jndiNameValidator = new JndiNameHelper();
String jndiStatus = jndiNameValidator.checkValidName(null);
this.sourceStatus = new Status(IStatus.ERROR, ModelGeneratorLdapUiConstants.PLUGIN_ID, jndiStatus);

SOURCE_MODEL_INFO: {
Group group = WidgetFactory.createGroup(parent, getString("sourceModelDefinition"), GridData.FILL_HORIZONTAL, 1, 3); //$NON-NLS-1$
Expand Down Expand Up @@ -200,11 +205,15 @@ public void modifyText(ModifyEvent e) {
importManager.setJBossJndiNameName(jndiName);
msgLabel.setText(JNDI_MESSAGE);
msgLabel.setImage(null);
sourceStatus = Status.OK_STATUS;
notifyChanged();
} else {
msgLabel.setText(jndiStatus);
msgLabel.setImage(UiPlugin.getDefault().getImage(UiPlugin.Images.ERROR_ICON));
jndiName = name;
importManager.setJBossJndiNameName(name);
sourceStatus = new Status(IStatus.ERROR, ModelGeneratorLdapUiConstants.PLUGIN_ID, jndiStatus);
notifyChanged();
}
}
});
Expand Down Expand Up @@ -270,6 +279,10 @@ public void refresh() {

refreshing = false;
}

public IStatus getModelStatus() {
return this.sourceStatus;
}

/**
* Uses the standard container selection dialog to choose the new value for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.teiid.designer.ui.common.widget.Label;
import org.teiid.designer.ui.common.wizard.AbstractWizardPage;
import org.teiid.designer.ui.explorer.ModelExplorerLabelProvider;
import org.teiid.designer.ui.util.JndiNameHelper;
import org.teiid.designer.ui.viewsupport.ModelNameUtil;
import org.teiid.designer.ui.viewsupport.ModelProjectSelectionStatusValidator;
import org.teiid.designer.ui.viewsupport.ModelResourceSelectionValidator;
Expand Down Expand Up @@ -110,13 +111,15 @@ public class ModelSelectionPage extends AbstractWizardPage

private Text jndiNameField;
private String jndiName;
private JndiNameHelper jndiNameValidator;
private Button autoCreateDataSource;

private IConnectionInfoHelper connectionInfoHelper;

public ModelSelectionPage( SalesforceImportWizardManager importManager ) {
super(ModelSelectionPage.class.getSimpleName(), getString("title")); //$NON-NLS-1$
this.importManager = importManager;
jndiNameValidator = new JndiNameHelper();
}

@Override
Expand Down Expand Up @@ -266,9 +269,11 @@ public void modifyText(ModifyEvent e) {
if( jndiNameField.getText() != null && jndiNameField.getText().length() > 0 ) {
jndiName = jndiNameField.getText();
importManager.setJBossJndiNameName(jndiName);
validateInput();
} else {
jndiName = ""; //$NON-NLS-1$
importManager.setJBossJndiNameName(null);
validateInput();
}

}
Expand Down Expand Up @@ -520,8 +525,8 @@ void handleBrowseWorkspaceForTargetModelLocation() {

void setPageStatus() {
// Validate the target relational model name and location
boolean targetValid = validateTargetModelNameAndLocation();
if (!targetValid) {
boolean isOk = validateInput();
if (!isOk) {
return;
}

Expand All @@ -544,7 +549,7 @@ public void handleEvent( Event event ) {
*
* @return 'true' if the selection is valid, 'false' if not.
*/
private boolean validateTargetModelNameAndLocation() {
private boolean validateInput() {
importManager.setCanFinish(updating = false);
try {
// Validate the target Model Name and location
Expand Down Expand Up @@ -598,6 +603,16 @@ private boolean validateTargetModelNameAndLocation() {
if (!updating) {
importManager.setCanFinish(true);
}


// Check JndiName

String jndiStatus = jndiNameValidator.checkValidName(importManager.getJBossJndiName());
if( jndiStatus != null ) {
WizardUtil.setPageComplete(this, jndiStatus, IMessageProvider.ERROR);
return false;
}

getContainer().updateButtons();
} catch (final CoreException err) {
UTIL.log(err);
Expand Down

0 comments on commit 321d047

Please sign in to comment.