Skip to content

Commit

Permalink
TEIIDDES-1469: Make the property keys more explicit
Browse files Browse the repository at this point in the history
* The source of the bug has been vague property keys. This starts to make
  the keys purpose obvious to avoid future mistakes.
  • Loading branch information
Paul Richardson committed Aug 29, 2012
1 parent fe21fe4 commit 3c6a108
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ protected Properties collectProperties() {
if (null == result) {
result = new Properties();
}
result.setProperty(IWSProfileConstants.URL_PROP_ID, urlText.getText());
result.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID, urlText.getText());
result.setProperty(ICredentialsCommon.SECURITY_TYPE_ID, securityText.getText());
result.setProperty(ICredentialsCommon.USERNAME_PROP_ID, usernameText.getText());
result.setProperty(ICredentialsCommon.PASSWORD_PROP_ID, passwordText.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void handleEvent(Event event) {
if (urlStr != null) {
urlStr = urlStr.trim();
}
setProperty(IWSProfileConstants.URL_PROP_ID, urlStr);
setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID, urlStr);
}
});

Expand Down Expand Up @@ -213,15 +213,15 @@ void updateState() {
descriptionText.setText(((NewConnectionProfileWizard)getWizard()).getProfileDescription());

Properties properties = ((NewConnectionProfileWizard)getWizard()).getProfileProperties();
if (null == properties.get(IWSProfileConstants.URL_PROP_ID)
|| properties.get(IWSProfileConstants.URL_PROP_ID).toString().isEmpty()) {
if (null == properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID)
|| properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString().isEmpty()) {
setErrorMessage(UTIL.getString("Common.URL.Error.Message")); //$NON-NLS-1$
return;
}
setErrorMessage(null);
try {
@SuppressWarnings("unused")
URL url = new URL(properties.get(IWSProfileConstants.URL_PROP_ID).toString());
URL url = new URL(properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString());
} catch(MalformedURLException e) {
setErrorMessage(UTIL.getString("Common.URL.Invalid.Message") + e.getMessage()); //$NON-NLS-1$
return;
Expand Down Expand Up @@ -269,8 +269,8 @@ private boolean internalComplete(boolean complete) {
Properties properties = ((NewConnectionProfileWizard) getWizard())
.getProfileProperties();
if (complete
&& (null == properties.get(IWSProfileConstants.URL_PROP_ID) || properties
.get(IWSProfileConstants.URL_PROP_ID).toString()
&& (null == properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID) || properties
.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString()
.isEmpty())) {
complete = false;
}
Expand Down Expand Up @@ -374,7 +374,7 @@ protected IStatus run( IProgressMonitor monitor ) {
}

public Exception testXmlUrlConnection( IConnectionProfile icp ) {
return WSWizardUtils.testURLConnection(icp, IWSProfileConstants.URL_PROP_ID);
return WSWizardUtils.testURLConnection(icp, IWSProfileConstants.END_POINT_URI_PROP_ID);
}

public Throwable getTestConnectionException( IConnection conn ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void handleEvent( Event event ) {
Properties properties = ((NewConnectionProfileWizard)getWizard()).getProfileProperties();
String urlStr = urlText.getText();
if (urlStr != null) urlStr = urlStr.trim();
properties.setProperty(IWSProfileConstants.URL_PROP_ID, urlStr);
properties.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID, urlStr);
}
updateState();
}
Expand Down Expand Up @@ -263,8 +263,8 @@ void updateState() {
descriptionText.setText(((NewConnectionProfileWizard)getWizard()).getProfileDescription());

Properties properties = ((NewConnectionProfileWizard)getWizard()).getProfileProperties();
if (null == properties.get(IWSProfileConstants.URL_PROP_ID)
|| properties.get(IWSProfileConstants.URL_PROP_ID).toString().isEmpty()) {
if (null == properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID)
|| properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString().isEmpty()) {
setErrorMessage(UTIL.getString("Common.URL.Error.Message")); //$NON-NLS-1$
return;
}
Expand All @@ -273,13 +273,13 @@ void updateState() {
boolean urlError = true;
try {
@SuppressWarnings("unused")
URL url = new URL(properties.get(IWSProfileConstants.URL_PROP_ID).toString());
URL url = new URL(properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString());
urlError = false;
} catch(MalformedURLException e) {

}
if( urlError ) {
File file = new File(properties.get(IWSProfileConstants.URL_PROP_ID).toString());
File file = new File(properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString());

if( !file.exists() && urlError) {
setErrorMessage(UTIL.getString("Common.URLorFILE.Invalid.Message")); //$NON-NLS-1$
Expand Down Expand Up @@ -313,8 +313,8 @@ private boolean internalComplete(boolean complete) {
Properties properties = ((NewConnectionProfileWizard) getWizard())
.getProfileProperties();
if (complete
&& (null == properties.get(IWSProfileConstants.URL_PROP_ID) || properties
.get(IWSProfileConstants.URL_PROP_ID).toString()
&& (null == properties.get(IWSProfileConstants.END_POINT_URI_PROP_ID) || properties
.get(IWSProfileConstants.END_POINT_URI_PROP_ID).toString()
.isEmpty())) {
complete = false;
}
Expand All @@ -336,7 +336,7 @@ public List getSummaryData() {
securityType = SecurityType.None.name();
}

result.add(new String[] { UTIL.getString("Common.URL.Label"), properties.getProperty(IWSProfileConstants.URL_PROP_ID) }); //$NON-NLS-1$
result.add(new String[] { UTIL.getString("Common.URL.Label"), properties.getProperty(IWSProfileConstants.END_POINT_URI_PROP_ID) }); //$NON-NLS-1$

if (! SecurityType.None.name().equals(securityType)) {
result.add(new String[] { UTIL.getString("Common.SecurityType.Label"), securityType }); //$NON-NLS-1$
Expand Down Expand Up @@ -417,7 +417,7 @@ protected IStatus run( IProgressMonitor monitor ) {
}

public Exception testXmlUrlConnection( IConnectionProfile icp ) {
return WSWizardUtils.testURLConnection(icp, IWSProfileConstants.URL_PROP_ID);
return WSWizardUtils.testURLConnection(icp, IWSProfileConstants.END_POINT_URI_PROP_ID);
}

public Throwable getTestConnectionException( IConnection conn ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected Properties collectProperties() {
if (null == result) {
result = new Properties();
}
result.setProperty(IWSProfileConstants.URL_PROP_ID, urlText.getText());
result.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID, urlText.getText());
result.setProperty(ICredentialsCommon.SECURITY_TYPE_ID, credentialsComposite.getSecurityOption().name());
result.setProperty(ICredentialsCommon.USERNAME_PROP_ID, credentialsComposite.getUserName());
result.setProperty(ICredentialsCommon.PASSWORD_PROP_ID, credentialsComposite.getPassword());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ public void clearConnectionInfo(ModelResource modelResource) throws ModelWorkspa
* @return 'endpoint' property value
*/
public static String readURLProperty(Properties properties) {
String urlPropId = properties.getProperty(IWSProfileConstants.URL_PROP_ID);
String urlPropId = properties.getProperty(IWSProfileConstants.END_POINT_URI_PROP_ID);
if (urlPropId == null) {
// Check for the legacy version that was getting used by the WSDL importer in 7.7.1
urlPropId = properties.getProperty(IWSProfileConstants.LEGACY_WSDL_PROP_ID);
urlPropId = properties.getProperty(IWSProfileConstants.WSDL_URI_PROP_ID);
}

return urlPropId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ public interface IWSProfileConstants extends ICredentialsCommon {
* The only property that matches up with the teiid-connector-ws.jar definition is the soapEndPoint
*
*/
String URL_PROP_ID = "EndPoint"; //$NON-NLS-1$
String SOAP_ENDPOINT_KEY = "soapEndPoint"; //$NON-NLS-1$
String CONNECTION_CLASS_KEY = "connectionClass"; //$NON-NLS-1$
String DRIVER_CLASS_PATH_KEY = "driverClassPath"; //$NON-NLS-1$

/**
* Used by the WSDL Importer in 7.7.1 for the wsdl URI connection profile property key.
* Should only be used for backward compatibilty
* Denotes the property key for the end point value(s) in a WSDL. In a connection
* profile, only 1 endpoint is selected from the selection available in a WSDL.
*/
String LEGACY_WSDL_PROP_ID = "wsdlURI"; //$NON-NLS-1$
String END_POINT_URI_PROP_ID = "EndPoint"; //$NON-NLS-1$

/**
* Denotes the property key for the WSDL URI. This is different to the WSDL endpoint
* key in that a number of endpoints can appear in a WSDL accessible from a URI.
*
* Also used incorrectly in 7.7.1 for the endpoint property key.
*/
String WSDL_URI_PROP_ID = "wsdlURI"; //$NON-NLS-1$
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void setConnectionInfo(ModelResource modelResource,

String url = readURLProperty(props);
if (null != url) {
connectionProps.setProperty(CONNECTION_NAMESPACE + IWSProfileConstants.URL_PROP_ID, url);
connectionProps.setProperty(CONNECTION_NAMESPACE + IWSProfileConstants.END_POINT_URI_PROP_ID, url);
}

String user = props.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
Expand Down Expand Up @@ -80,7 +80,7 @@ public Properties getTeiidRelatedProperties(

String url = readURLProperty(props);
if (null != url) {
connectionProps.setProperty(IWSProfileConstants.URL_PROP_ID, url);
connectionProps.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID, url);
}

String user = props.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public interface IXmlProfileConstants extends ICredentialsCommon {
String LOCAL_FILE_PATH_PROP_ID = "LocalFilePath"; //$NON-NLS-1$
String TEIID_PARENT_DIRECTORY_KEY = "ParentDirectory"; //$NON-NLS-1$

String WS_ENDPOINT_KEY = IWSProfileConstants.URL_PROP_ID;
String WS_ENDPOINT_KEY = IWSProfileConstants.END_POINT_URI_PROP_ID;

}
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected void addConnectionProfileInfoToSourceModel(IProgressMonitor monitor, b
String endpoint = this.importManager.getEndPoint();
if( endpoint != null ) {
Properties props = profile.getBaseProperties();
props.put(IWSProfileConstants.URL_PROP_ID, endpoint);
props.put(IWSProfileConstants.END_POINT_URI_PROP_ID, endpoint);
String defaultServiceMode = this.importManager.getTranslatorDefaultServiceMode();
if( defaultServiceMode.equalsIgnoreCase(WSDLImportWizardManager.MESSAGE ) ) {
props.put(IWSProfileConstants.SOAP_SERVICE_MODE, WSDLImportWizardManager.MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void setConnectionInfo( ModelResource modelResource,

String url = readURLProperty(props);
if (url != null) {
connectionProps.put(CONNECTION_NAMESPACE + URL_PROP_ID, url);
connectionProps.put(CONNECTION_NAMESPACE + END_POINT_URI_PROP_ID, url);
}

if (props.getProperty(CONNECTION_CLASS_KEY) != null) {
Expand Down

0 comments on commit 3c6a108

Please sign in to comment.