Skip to content

Commit

Permalink
TEIIDDES-3046
Browse files Browse the repository at this point in the history
 * refactored AdminFactory instances
 * created separate cache classes for Translators, Data Sources and RAs
 * Changed JNDI name workflow/entry to required java:/ prefix from user
  • Loading branch information
blafond committed May 22, 2017
1 parent d4aac4d commit d8fb4da
Show file tree
Hide file tree
Showing 61 changed files with 5,837 additions and 2,375 deletions.
@@ -0,0 +1,24 @@
package org.teiid.designer.core.util;

public class JndiUtil {
public static final String JAVA_PREFIX = "java:/";

public static String addJavaPrefix(String name) {
if( !name.startsWith(JAVA_PREFIX) ) {
return JAVA_PREFIX + name;
}

return name;
}

public static String removeJavaPrefix(String nameWithPrefix) {
if (nameWithPrefix.startsWith(JAVA_PREFIX)) {
nameWithPrefix = nameWithPrefix.substring(6);
}
return nameWithPrefix;
}

public static boolean hasJavaPrefix(String jndiName) {
return jndiName.startsWith(JAVA_PREFIX);
}
}
Expand Up @@ -29,13 +29,13 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.datatools.profiles.jbossds.IJBossDsProfileConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiConstants;
import org.teiid.designer.datatools.ui.dialogs.ScrolledConnectionProfileDetailsPage;
import org.teiid.designer.ui.common.util.WidgetFactory;

public class JDGProfileDetailsWizardPage extends ScrolledConnectionProfileDetailsPage implements IJDGProfileConstants.PropertyKeys, Listener, DatatoolsUiConstants {
private static final String JNDI_PREFIX = "java:/"; //$NON-NLS-1$
private Composite scrolled;

private CLabel profileText;
Expand Down Expand Up @@ -436,7 +436,8 @@ public void handleEvent( Event event ) {

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

updateState();
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.swt.widgets.Text;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.datatools.profiles.jbossds.IJBossDsProfileConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiPlugin;
Expand Down Expand Up @@ -132,7 +133,8 @@ protected void createCustomContents(Composite parent) {

@Override
public void modifyText(ModifyEvent e) {
setProperty(IJBossDsProfileConstants.JNDI_PROP_ID, jndiText.getText());
String jndiName = JndiUtil.addJavaPrefix(jndiText.getText());
setProperty(IJBossDsProfileConstants.JNDI_PROP_ID, jndiName);
}
});

Expand Down Expand Up @@ -347,7 +349,6 @@ public void modifyText(ModifyEvent e) {

@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("schemaAnotationsRB SELECTED");
updateState();
}

Expand Down
Expand Up @@ -33,15 +33,23 @@ public DataSourceConnectionHelper(ModelResource mr) {
}

public Properties getModelConnectionProperties() {
if (provider != null) {
Properties properties = provider.getTeiidRelatedProperties(cp);
if (properties != null && !properties.isEmpty()) {
return properties;
}
IConnectionInfoProvider theProvider = null;
try {
theProvider = getProvider();
} catch (Exception e) {
// If provider throws exception its OK because some models may not have connection info.
}

return null;
if( theProvider != null ) {
Properties properties = theProvider.getTeiidRelatedProperties(cp);

if (properties != null && !properties.isEmpty()) {
return properties;
}
}

return new Properties();
}

public String getDataSourceType() {
Expand Down
Expand Up @@ -100,13 +100,6 @@ public Properties getTeiidRelatedProperties(IConnectionProfile connectionProfile
}

connectionProps.setProperty(CLASS_NAME, IJDGProfileConstants.REQUIRED_CLASS_NAME);

System.out.println("JDGConnectionInfoProvider.getTeiidRelatedProps()");
System.out.println(" ====================================");
for( Object prop : connectionProps.keySet() ) {
System.out.println(" key = " + (String)prop + " value = " + connectionProps.getProperty((String)prop));
}
System.out.println(" ====================================");

return connectionProps;
}
Expand Down
Expand Up @@ -44,6 +44,7 @@
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.core.validation.rules.StringNameValidator;
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.core.workspace.ModelUtil;
Expand Down Expand Up @@ -79,8 +80,6 @@ public class CreateDataSourceWizard extends ScrollableTitleAreaDialog implements
private static final String HIDDEN_PASSWORD = "********"; //$NON-NLS-1$
private static final String NEW_BUTTON = DqpUiConstants.UTIL.getString("Button.newLabel"); //$NON-NLS-1$
private static final String EDIT_BUTTON = DqpUiConstants.UTIL.getString("Button.editLabel"); //$NON-NLS-1$

private static final String JNDI_PREFIX = "java:/"; //$NON-NLS-1$

private static String getString( final String id ) {
return DqpUiConstants.UTIL.getString(I18N_PREFIX + id);
Expand Down Expand Up @@ -180,19 +179,10 @@ protected Control createDialogArea( final Composite parent ) {
if (selectedModelResource != null) {
ConnectionInfoHelper helper = new ConnectionInfoHelper();
dataSourceName = helper.getJndiProperty(selectedModelResource);
// Strip off "java:/"
String nameOnly = StringConstants.EMPTY_STRING;

if( !StringUtilities.isEmpty(dataSourceName) ) {
nameOnly = dataSourceName;
if( dataSourceName.startsWith(JNDI_PREFIX) ) {
nameOnly = dataSourceName.substring(6);
}
dataSourceName = nameOnly;

if( StringUtilities.isEmpty(dataSourceName) ) {
dataSourceName = JndiUtil.addJavaPrefix(ModelUtil.getName(selectedModelResource));
}
if( dataSourceName == null ) {
dataSourceName = ModelUtil.getName(selectedModelResource);
}
}

this.dataSourceNameText = WidgetFactory.createTextField(mainPanel, GridData.FILL_HORIZONTAL, 1, dataSourceName);
Expand Down Expand Up @@ -692,7 +682,7 @@ class DataSourceNameValidator extends StringNameValidator {

public DataSourceNameValidator( int minLength,
int maxLength ) {
super(minLength, maxLength, new char[] {UNDERSCORE_CHARACTER, '-', '.'});
super(minLength, maxLength, new char[] {UNDERSCORE_CHARACTER, '-', '.', ':', '/'});
}

@Override
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.teiid.core.designer.util.StringConstants;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.datatools.connection.ConnectionInfoHelper;
import org.teiid.designer.runtime.ui.DqpUiConstants;
Expand All @@ -41,7 +42,6 @@

public class JndiNameInModelHelper {
private static final String DIALOG_TITLE = DqpUiConstants.UTIL.getString("EnterDataSourceJNDINameDialog.title"); //$NON-NLS-1$
private static final String JNDI_PREFIX = "java:/"; //$NON-NLS-1$

private ConnectionInfoHelper connectionInfoHelper;

Expand All @@ -51,14 +51,10 @@ public JndiNameInModelHelper() {

public String getExistingJndiName(ModelResource mr) {
String existingName = connectionInfoHelper.getJndiProperty(mr);
// Strip off "java:/"
String nameOnly = StringConstants.EMPTY_STRING;

if( !StringUtilities.isEmpty(existingName) ) {
nameOnly = existingName;
if( existingName.startsWith(JNDI_PREFIX) ) {
nameOnly = existingName.substring(6);
}
nameOnly = JndiUtil.removeJavaPrefix(existingName);
}

return nameOnly;
Expand Down Expand Up @@ -113,7 +109,7 @@ public boolean ensureJndiNameExists(ModelResource mr, boolean queryOnlyIfEmpty)
if( StringUtilities.isEmpty(newJNDIName) ) {
setJNDINameInTxn(mr, null);
} else if( existingName == null || !existingName.equals(newJNDIName)) {
setJNDINameInTxn(mr, JNDI_PREFIX + newJNDIName);
setJNDINameInTxn(mr, /*JNDI_PREFIX +*/ newJNDIName);
return true;
}
}
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.teiid.core.designer.util.FileUtils;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.core.workspace.ModelUtil;
import org.teiid.designer.datatools.connection.ConnectionInfoProviderFactory;
Expand All @@ -44,7 +45,7 @@ public class VdbDeployer {
static final String PREFIX = I18nUtil.getPropertyPrefix(VdbDeployer.class);

private static final String JNDI_PROPERTY_KEY = "jndi-name"; //$NON-NLS-1$
private static final String JNDI_CONTEXT = "java:/"; //$NON-NLS-1$


/**
* A VDB deployment status.
Expand Down Expand Up @@ -214,9 +215,7 @@ public String deploy( IProgressMonitor monitor ) {
// auto-create if jndiName not different than sourceName
String jndiNameWithoutContext = jndiName;
// incoming jndiName may not have context, so try that also since server can match it
if(jndiName.startsWith(JNDI_CONTEXT)) {
jndiNameWithoutContext = jndiName.substring(JNDI_CONTEXT.length());
}
jndiNameWithoutContext = JndiUtil.removeJavaPrefix(jndiName);

if (sourceName.equals(jndiNameWithoutContext) && this.autoCreateDsOnServer) {
autoCreate = true; // create without asking user
Expand Down Expand Up @@ -377,8 +376,8 @@ private boolean dataSourceWithJndiExists(String jndiName) {
break;
}
// incoming jndiName may not have context, so try that also since server can match it
if(!jndiName.startsWith(JNDI_CONTEXT)) {
String jndiNameWithContext = JNDI_CONTEXT+jndiName;
if(!JndiUtil.hasJavaPrefix(jndiName)) {
String jndiNameWithContext = JndiUtil.addJavaPrefix(jndiName);
if(serverJndiName.equalsIgnoreCase(jndiNameWithContext)) {
hasSourceWithJndi = true;
break;
Expand Down
Expand Up @@ -10,6 +10,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.server.core.IServer;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.core.designer.util.StringUtilities;
import org.teiid.designer.runtime.connection.SourceConnectionBinding;
import org.teiid.designer.runtime.spi.ITeiidDataSource;
import org.teiid.designer.runtime.spi.ITeiidServer;
Expand Down Expand Up @@ -82,18 +83,23 @@ public void dispose() {
@Override
public String getName() {
if (value instanceof ITeiidDataSource) {
String nodeName = null;
String poolName = null;

if (((ITeiidDataSource) value).getDisplayName() != null) {
nodeName = ((ITeiidDataSource) value).getDisplayName();
poolName = ((ITeiidDataSource) value).getDisplayName();
}
nodeName = ((ITeiidDataSource) value).getName();
poolName = ((ITeiidDataSource) value).getName();
String jndiName = ((ITeiidDataSource)value).getPropertyValue("jndi-name"); //$NON-NLS-1$
if(jndiName!=null && !jndiName.isEmpty()) {
nodeName += " [JNDI: " + jndiName + "]"; //$NON-NLS-1$ //$NON-NLS-2$
String nodeName;
if(StringUtilities.isNotEmpty(jndiName)) {
nodeName = jndiName;
} else {
nodeName += " [JNDI: java:/" + nodeName + "]"; //$NON-NLS-1$ //$NON-NLS-2$
nodeName = poolName;
}

nodeName += " - - - [pool-name = " + poolName + "]"; //$NON-NLS-1$ //$NON-NLS-2$

return nodeName;
}

Expand Down
Expand Up @@ -52,6 +52,7 @@
import org.teiid.core.designer.util.TempDirectory;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.types.DatatypeConstants;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.core.workspace.ModelUtil;
import org.teiid.designer.runtime.ui.wizards.webservices.WarDeploymentInfoPanel;
import org.teiid.designer.ui.util.ErrorHandler;
Expand All @@ -72,7 +73,6 @@ public class DefaultWebArchiveBuilderImpl implements WebArchiveBuilder, WebServi
private List<String> ports = new ArrayList<String>();
private Map<String, String> operationToProcedureMap = new HashMap<String, String>();
private String wsdlFilename = CoreStringUtil.Constants.EMPTY_STRING;
private static final String JNDI_PREFIX = "java:"; //$NON-NLS-1$

// =============================================================
// Constants
Expand Down Expand Up @@ -501,8 +501,8 @@ private void createPropertiesFile( File webInfClassesDirectory,
File teiisSoapProperties = new File(webInfClassesDirectory + File.separator + TEIID_SOAP_PROPS);
String jndiValue = properties.getProperty(WebArchiveBuilderConstants.PROPERTY_JNDI_NAME);

if (jndiValue != null && !jndiValue.startsWith(JNDI_PREFIX)) {
jndiValue = JNDI_PREFIX + FORWARD_SLASH + jndiValue;
if (jndiValue != null) {
jndiValue = JndiUtil.addJavaPrefix(jndiValue);
}

FileWriter fstream = null;
Expand Down
Expand Up @@ -44,6 +44,7 @@
import org.teiid.core.designer.util.TempDirectory;
import org.teiid.designer.DesignerSPIPlugin;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.util.JndiUtil;
import org.teiid.designer.runtime.ui.wizards.webservices.WarDeploymentInfoPanel;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;
Expand Down Expand Up @@ -75,7 +76,6 @@ public class RestWebArchiveBuilderImpl implements WebArchiveBuilder, WebServiceL
private static final String TASK_CREATING_WAR_ARCHIVE = getString("taskCreatingWarArchive"); //$NON-NLS-1$
private static final String TASK_COPYING_WAR_FILE = getString("taskCopyingWarFile"); //$NON-NLS-1$
private static final String TASK_CLEANUP = getString("taskCleanup"); //$NON-NLS-1$
private static final String JNDI_PREFIX = "java:"; //$NON-NLS-1$

/**
* This constructor is package protected, so that only the factory can call it.
Expand Down Expand Up @@ -445,8 +445,8 @@ private void createPropertiesFile( File webInfClassesDirectory,
File teiidRestProperties = new File(webInfClassesDirectory + File.separator +TEIID_REST_PROPS);
String jndiValue = properties.getProperty(WebArchiveBuilderConstants.PROPERTY_JNDI_NAME);

if (jndiValue != null && !jndiValue.startsWith(JNDI_PREFIX)) {
jndiValue = JNDI_PREFIX + FORWARD_SLASH + jndiValue;
if (jndiValue != null) {
jndiValue = JndiUtil.addJavaPrefix(jndiValue);
}

ITeiidServerVersion teiidVersion = ModelerCore.getTeiidServerVersion();
Expand Down
Expand Up @@ -42,6 +42,8 @@ public class TeiidParentServerListener implements IServerLifecycleListener, ISer
* Could not execute "read-children-names" for undefined. Failure was "JBAS013493: System boot is in process; execution of remote management operations is not currently available".
*/
public static String JBAS013493_CODE = "JBAS013493"; //$NON-NLS-1$

public static String MISSING_NLS_MESSAGE = "NLS missing message: OperationOnAddressFailed in"; //$NON-NLS-1$

/**
* Get the singleton instance of of this class
Expand Down Expand Up @@ -78,7 +80,8 @@ public void serverAdded(IServer server) {
try {
factory.adaptServer(server, ServerOptions.NO_CHECK_CONNECTION, ServerOptions.ADD_TO_REGISTRY);
} catch (final Exception ex) {
if(! ex.getMessage().contains(TeiidParentServerListener.JBAS013493_CODE)) {
if(! ex.getMessage().contains(TeiidParentServerListener.JBAS013493_CODE) &&
! ex.getMessage().contains(TeiidParentServerListener.MISSING_NLS_MESSAGE)) {
DqpPlugin.handleException(ex);
}
}
Expand Down

0 comments on commit d8fb4da

Please sign in to comment.