Skip to content

Commit

Permalink
TEIIDDES-1518: Implement support in the server view for teiid 7.7.x
Browse files Browse the repository at this point in the history
* Implements support in
 * TeiidServerAdaptorFactory
 * Teiid Server Editor Page
 * New Teiid Server Wizard

* Teiid 7.x default to the admin connection being ssl enabled so checkboxes
  have been located on UI elements, only if a 7.x teiid server has been
  chosen.
  • Loading branch information
Paul Richardson committed Dec 14, 2012
1 parent 740d496 commit 750a873
Show file tree
Hide file tree
Showing 13 changed files with 350 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ serverPageServerNotStarted = The new jboss server has not been started
serverPageNewServerNotCompatibleWithTeiid =The new server does has not been configured with teiid or is not compatible. Ensure that it is at least a JBoss version 7+ instance.
serverPageEmptyCustomLabelMsg = Name cannot be empty

serverPageSecureConnectionInfoLabel = Teiid Secure Connection Info
serverPageSecureConnAdminLabel = Admin connection uses SSL ( pre-8 servers )
serverPageSecureConnJDBCLabel = JDBC connection uses SSL

serverWizardEditServerErrorMsg = There were errors editing a Teiid instance. See log for more details.
serverWizardEditServerTitle = Edit Teiid Instance
serverWizardNewServerErrorMsg = There were errors creating a new Teiid instance. See log for more details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
Expand All @@ -38,10 +41,12 @@
import org.teiid.designer.runtime.TeiidServerFactory.ServerOptions;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.adapter.TeiidServerAdapterFactory;
import org.teiid.designer.runtime.spi.ITeiidAdminInfo;
import org.teiid.designer.runtime.spi.ITeiidJdbcInfo;
import org.teiid.designer.runtime.spi.ITeiidServer;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.ui.common.util.WidgetFactory;


Expand Down Expand Up @@ -80,6 +85,10 @@ public final class ServerPage extends WizardPage {
private Text jdbcPasswordText;

private Text jdbcURLText;

private Button adminSSLButton;

private Button jdbcSSLButton;

private IServerLifecycleListener serverLifecycleListener = new IServerLifecycleListener() {

Expand Down Expand Up @@ -249,6 +258,39 @@ public void focusLost(FocusEvent e) {
}

}

private void constructSecureConnectionPanel(Composite parent) {
Group teiidSSLGroup = WidgetFactory.createGroup(parent, UTIL.getString("serverPageSecureConnectionInfoLabel")); //$NON-NLS-1$);
GridDataFactory.fillDefaults().applyTo(teiidSSLGroup);
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 5).applyTo(teiidSSLGroup);

{ // admin ssl
adminSSLButton = new Button(teiidSSLGroup, SWT.CHECK);
adminSSLButton.setText(UTIL.getString("serverPageSecureConnAdminLabel")); //$NON-NLS-1$
GridDataFactory.swtDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(adminSSLButton);
adminSSLButton.setToolTipText(UTIL.getString("serverPageSecureConnAdminLabel")); //$NON-NLS-1$
adminSSLButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handlePropertiesModified();
}
});
}

{ // jdbc ssl
jdbcSSLButton = new Button(teiidSSLGroup, SWT.CHECK);
jdbcSSLButton.setText(UTIL.getString("serverPageSecureConnJDBCLabel")); //$NON-NLS-1$
GridDataFactory.swtDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(jdbcSSLButton);
jdbcSSLButton.setToolTipText(UTIL.getString("serverPageSecureConnJDBCLabel")); //$NON-NLS-1$
jdbcSSLButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handlePropertiesModified();
}
});
}

}

/**
* {@inheritDoc}
Expand All @@ -266,6 +308,7 @@ public void createControl( Composite parent ) {
// Add display name component
constructDisplayNamePanel(pnlMain);
constructIServerCreationPanel(pnlMain);
constructSecureConnectionPanel(pnlMain);
constructTeiidJdbcConnectionPanel(pnlMain);

setControl(pnlMain);
Expand Down Expand Up @@ -317,6 +360,17 @@ public void run() {

jbossServerNameText.setText(server.getName());

if (ITeiidServerVersion.SEVEN.equals(teiidServer.getServerVersion().getMajor())) {
ITeiidAdminInfo teiidAdminInfo = teiidServer.getTeiidAdminInfo();
adminSSLButton.setSelection(teiidAdminInfo.isSecure());
adminSSLButton.setEnabled(true);
}
else {
// Not a 7.x server so disable the button
adminSSLButton.setSelection(false);
adminSSLButton.setEnabled(false);
}

ITeiidJdbcInfo teiidJdbcInfo = teiidServer.getTeiidJdbcInfo();

if (ITeiidJdbcInfo.DEFAULT_JDBC_USERNAME.equals(jdbcUsernameText.getText()))
Expand All @@ -325,6 +379,8 @@ public void run() {
if (ITeiidJdbcInfo.DEFAULT_JDBC_PASSWORD.equals(jdbcPasswordText.getText()))
jdbcPasswordText.setText(teiidJdbcInfo.getPassword());

jdbcSSLButton.setSelection(teiidJdbcInfo.isSecure());

jdbcURLText.setText(teiidJdbcInfo.getUrl());

String displayName = displayNameText.getText();
Expand All @@ -345,9 +401,13 @@ private void handlePropertiesModified() {
if (teiidServer != null) {
teiidServer.setCustomLabel(displayNameText.getText());

ITeiidAdminInfo teiidAdminInfo = teiidServer.getTeiidAdminInfo();
teiidAdminInfo.setSecure(adminSSLButton.getSelection());

ITeiidJdbcInfo teiidJdbcInfo = teiidServer.getTeiidJdbcInfo();
teiidJdbcInfo.setUsername(jdbcUsernameText.getText());
teiidJdbcInfo.setPassword(jdbcPasswordText.getText());
teiidJdbcInfo.setSecure(jdbcSSLButton.getSelection());

jdbcURLText.setText(teiidJdbcInfo.getUrl());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
Expand All @@ -37,8 +40,10 @@
import org.teiid.designer.runtime.spi.ExecutionConfigurationEvent;
import org.teiid.designer.runtime.spi.ExecutionConfigurationEvent.TargetType;
import org.teiid.designer.runtime.spi.IExecutionConfigurationListener;
import org.teiid.designer.runtime.spi.ITeiidAdminInfo;
import org.teiid.designer.runtime.spi.ITeiidJdbcInfo;
import org.teiid.designer.runtime.spi.ITeiidServer;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.ui.common.util.WidgetFactory;

/**
Expand Down Expand Up @@ -72,6 +77,8 @@ public class TeiidServerEditor extends EditorPart {
private Text versionText;

private FormText adminDescriptionText;

private Button adminSSLCheckbox;

private Hyperlink adminPingHyperlink;

Expand All @@ -82,6 +89,8 @@ public class TeiidServerEditor extends EditorPart {
private Text jdbcPasswdText;

private Label jdbcPort;

private Button jdbcSSLCheckbox;

private Hyperlink jdbcPingHyperlink;

Expand Down Expand Up @@ -113,6 +122,13 @@ public void keyReleased(KeyEvent e) {
}
};

private SelectionListener dirtySelectionListener = new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
TeiidServerEditor.this.setDirty();
}
};

@Override
public void init(IEditorSite site, IEditorInput input) {
setSite(site);
Expand Down Expand Up @@ -227,6 +243,14 @@ private void createAdminSection(Composite parent) {
blueForeground(adminDescriptionText);
GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(adminDescriptionText);

if (ITeiidServerVersion.SEVEN.equals(teiidServer.getServerVersion().getMajor())) {
adminSSLCheckbox = toolkit.createButton(composite, UTIL.getString("serverPageSecureConnAdminLabel"), SWT.CHECK); //$NON-NLS-1$
adminSSLCheckbox.setSelection(teiidServer.getTeiidAdminInfo().isSecure());
blueForeground(adminSSLCheckbox);
adminSSLCheckbox.addSelectionListener(dirtySelectionListener);
GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(adminSSLCheckbox);
}

adminPingHyperlink = toolkit.createHyperlink(composite, UTIL.getString("TeiidServerAdminSection.testPingButtonLabel"), SWT.NONE); //$NON-NLS-1$
GridDataFactory.fillDefaults().grab(true, false).applyTo(adminPingHyperlink);
adminPingHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
Expand Down Expand Up @@ -280,6 +304,12 @@ private void createJDBCSection(Composite parent) {
jdbcPort = toolkit.createLabel(composite, teiidServer.getTeiidJdbcInfo().getPort());
blueForeground(jdbcPort);

jdbcSSLCheckbox = toolkit.createButton(composite, UTIL.getString("serverPageSecureConnJDBCLabel"), SWT.CHECK); //$NON-NLS-1$
jdbcSSLCheckbox.setSelection(teiidServer.getTeiidJdbcInfo().isSecure());
blueForeground(jdbcSSLCheckbox);
jdbcSSLCheckbox.addSelectionListener(dirtySelectionListener);
GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(jdbcSSLCheckbox);

jdbcPingHyperlink = toolkit.createHyperlink(composite, UTIL.getString("TeiidServerJDBCSection.testPingButtonLabel"), SWT.NONE); //$NON-NLS-1$
GridDataFactory.fillDefaults().grab(true, false).applyTo(jdbcPingHyperlink);
jdbcPingHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
Expand Down Expand Up @@ -337,9 +367,15 @@ public void doSave(IProgressMonitor monitor) {
// Overwrite the properties of the teiid server
teiidServer.setCustomLabel(customNameText.getText());

if (adminSSLCheckbox != null) {
ITeiidAdminInfo adminInfo = teiidServer.getTeiidAdminInfo();
adminInfo.setSecure(adminSSLCheckbox.getSelection());
}

ITeiidJdbcInfo jdbcInfo = teiidServer.getTeiidJdbcInfo();
jdbcInfo.setUsername(jdbcUserNameText.getText());
jdbcInfo.setPassword(jdbcPasswdText.getText());
jdbcInfo.setSecure(jdbcSSLCheckbox.getSelection());

dirty = false;
firePropertyChange(IEditorPart.PROP_DIRTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ public enum ServerOptions {
/**
* Do NOT query whether the parent {@link IServer} is connected
*/
NO_CHECK_CONNECTION
NO_CHECK_CONNECTION,

/**
* Server uses secure connections for admin requests
*/
ADMIN_SECURE_CONNECTION,

/**
* Server uses secure connections for jdbc requests
*/
JDBC_SECURE_CONNECTION
}

/**
Expand All @@ -60,6 +70,14 @@ private void processOptions(ITeiidServer teiidServer, TeiidServerManager serverM
if (options != null)
optionList = Arrays.asList(options);

if (optionList.contains(ServerOptions.ADMIN_SECURE_CONNECTION)) {
teiidServer.getTeiidAdminInfo().setSecure(true);
}

if (optionList.contains(ServerOptions.JDBC_SECURE_CONNECTION)) {
teiidServer.getTeiidJdbcInfo().setSecure(true);
}

if (optionList.contains(ServerOptions.CONNECT)) {
// Connect this teiid server
try {
Expand Down Expand Up @@ -126,7 +144,7 @@ public ITeiidServer createTeiidServer(ITeiidServerVersion serverVersion,
* @param parentServer
* @param options
*
* @return
* @return instance of {@link ITeiidServer}
*/
public ITeiidServer createTeiidServer(ITeiidServerVersion serverVersion,
ITeiidAdminInfo teiidAdminInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,22 @@ public ITeiidServer getServer( String url ) {
return null;
}

/**
* @param parentServer the parent server of the requested teiid server
* @return the requested server or <code>null</code> if not found in the registry
*/
public ITeiidServer getServer( IServer parentServer) {
CoreArgCheck.isNotNull(parentServer, "parentServer"); //$NON-NLS-1$

for (ITeiidServer teiidServer : getServers()) {
if (parentServer.equals(teiidServer.getParent())) {
return teiidServer;
}
}

return null;
}

/**
* @return an unmodifiable collection of registered servers (never <code>null</code>)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,29 @@
/**
* @since 8.0
*/
public abstract class JBoss7ServerUtil extends ModelDescriptionConstants {
public abstract class JBoss7ServerUtil extends JBossServerUtil {

private static final String OP = ModelDescriptionConstants.OP;

private static final String NAME = ModelDescriptionConstants.NAME;

private static final String READ_ATTRIBUTE_OPERATION = ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;

private static final String READ_CHILDREN_NAMES_OPERATION = ModelDescriptionConstants.READ_CHILDREN_NAMES_OPERATION;

private static final String SUBSYSTEM = ModelDescriptionConstants.SUBSYSTEM;

private static final String CHILD_TYPE = ModelDescriptionConstants.CHILD_TYPE;

private static final String SOCKET_BINDING_GROUP = ModelDescriptionConstants.SOCKET_BINDING_GROUP;

private static final String SOCKET_BINDING = ModelDescriptionConstants.SOCKET_BINDING;

private static final String OP_ADDR = ModelDescriptionConstants.OP_ADDR;

private static final String PORT = ModelDescriptionConstants.PORT;


/**
* @param server
* @param request
Expand All @@ -38,23 +59,6 @@ private static ModelNode executeRequest(JBoss7Server jboss7Server, ModelNode req
return ModelNode.fromJSONString(resultString);
}

/**
* Test the given server for whether its been started
*
* @param jboss7Server
*
* @return true is server is in the started state
*/
private static boolean serverStarted(JBoss7Server jboss7Server) {
if (jboss7Server == null)
return false;

if (jboss7Server.getServer().getServerState() != IServer.STATE_STARTED)
return false;

return true;
}

/**
* Determine whether the jboss 7 server is contactable by attempting
* to talk to its management port
Expand Down Expand Up @@ -85,6 +89,7 @@ public static boolean isJBossServerConnected(JBoss7Server jboss7Server) {
* Determine whether the given server has teiid support
*
* @param jboss7Server
*
* @return true is server has teiid support, false otherwise
*/
public static boolean isTeiidServer(JBoss7Server jboss7Server) {
Expand Down

0 comments on commit 750a873

Please sign in to comment.