/** * Validates public and private ports. And also makes changes corresponding to the debug endpoint. * * @param oldEndptName : old name of the endpoint. * @return retVal : false if any error occurs. * @throws WindowsAzureInvalidProjectOperationException */ private boolean validatePorts(String oldEndptName) throws WindowsAzureInvalidProjectOperationException { boolean retVal = true; WindowsAzureEndpointType oldType = waEndpt.getEndPointType(); WindowsAzureEndpoint debugEndpt = windowsAzureRole.getDebuggingEndpoint(); WindowsAzureEndpoint stickyEndpt = windowsAzureRole.getSessionAffinityInputEndpoint(); WindowsAzureEndpoint stickyIntEndpt = windowsAzureRole.getSessionAffinityInternalEndpoint(); String stcEndptName = ""; String dbgEndptName = ""; String stcIntEndptName = ""; if (debugEndpt != null) { // get the debugging endpoint name dbgEndptName = debugEndpt.getName(); } if (stickyEndpt != null) { stcEndptName = stickyEndpt.getName(); stcIntEndptName = stickyIntEndpt.getName(); } // validate ports boolean isValidendpoint = windowsAzureRole.isValidEndpoint( oldEndptName, WindowsAzureEndpointType.valueOf(comboType.getText()), txtPrivatePort.getText(), txtPublicPort.getText()); if (isValidendpoint) { if (oldEndptName.equalsIgnoreCase(dbgEndptName)) { retVal = handleChangeForDebugEndpt(oldType); } if (oldEndptName.equalsIgnoreCase(stcEndptName)) { retVal = handleChangeForStickyEndpt(oldType); } if (oldEndptName.equalsIgnoreCase(stcIntEndptName)) { retVal = handleChangeForStickyEndpt(oldType); } if (retVal) { // set the new values in the endpoint object. waEndpt.setEndPointType(WindowsAzureEndpointType.valueOf(comboType.getText())); waEndpt.setName(txtName.getText()); if (comboType.getText().equalsIgnoreCase(WindowsAzureEndpointType.Input.toString()) || comboType .getText() .equalsIgnoreCase(WindowsAzureEndpointType.InstanceInput.toString())) { waEndpt.setPort(txtPublicPort.getText()); } waEndpt.setPrivatePort(txtPrivatePort.getText()); } } else { errorTitle = Messages.dlgInvldPort; errorMessage = Messages.dlgPortInUse; MessageUtil.displayErrorDialog(this.getShell(), errorTitle, errorMessage); retVal = false; } return retVal; }
/** * Disables the debugging if debug endpoint's type is changed to 'Internal', and if private port * is modified then assigns the new debugging port by setting the modified endpoint as a debugging * endpoint. * * @param oldType : old type of the endpoint. * @return retVal : false if any error occurs. * @throws WindowsAzureInvalidProjectOperationException */ private boolean handleChangeForDebugEndpt(WindowsAzureEndpointType oldType) throws WindowsAzureInvalidProjectOperationException { boolean retVal = true; if (oldType.equals(WindowsAzureEndpointType.Input) && comboType.getText().equalsIgnoreCase(WindowsAzureEndpointType.Internal.toString())) { StringBuffer msg = new StringBuffer(Messages.dlgEPDel); msg.append(Messages.dlgEPChangeType); msg.append(Messages.dlgEPDel2); boolean choice = MessageDialog.openQuestion(new Shell(), Messages.dlgTypeTitle, msg.toString()); if (choice) { waEndpt.setEndPointType(WindowsAzureEndpointType.valueOf(comboType.getText())); windowsAzureRole.setDebuggingEndpoint(null); } else { retVal = false; } } else if (!waEndpt.getPrivatePort().equalsIgnoreCase(txtPrivatePort.getText())) { boolean isSuspended = windowsAzureRole.getStartSuspended(); windowsAzureRole.setDebuggingEndpoint(null); waEndpt.setPrivatePort(txtPrivatePort.getText()); windowsAzureRole.setDebuggingEndpoint(waEndpt); windowsAzureRole.setStartSuspended(isSuspended); } return retVal; }
@Override protected void okPressed() { boolean okToProceed = true; try { if (isEditEndpt) { // if its an edit an endpoint scenario okToProceed = editEndpt(); } else { // for add an endpoint scenario boolean isValid = windowsAzureRole.isAvailableEndpointName(txtName.getText()); if (isValid) { boolean isValidendpoint = windowsAzureRole.isValidEndpoint( txtName.getText(), WindowsAzureEndpointType.valueOf(comboType.getText()), txtPrivatePort.getText(), txtPublicPort.getText()); if (isValidendpoint) { windowsAzureRole.addEndpoint( txtName.getText(), WindowsAzureEndpointType.valueOf(comboType.getText()), txtPrivatePort.getText(), txtPublicPort.getText()); } else { errorTitle = Messages.dlgInvldPort; errorMessage = Messages.dlgPortInUse; MessageUtil.displayErrorDialog(this.getShell(), errorTitle, errorMessage); okToProceed = false; } } else { errorTitle = Messages.dlgInvdEdPtName1; errorMessage = Messages.dlgInvdEdPtName2; MessageUtil.displayErrorDialog(this.getShell(), errorTitle, errorMessage); okToProceed = false; } } } catch (WindowsAzureInvalidProjectOperationException e) { errorTitle = Messages.rolsErr; errorMessage = Messages.adRolErrMsgBox1 + Messages.adRolErrMsgBox2; MessageUtil.displayErrorDialog(this.getShell(), errorTitle, errorMessage); Activator.getDefault().log(errorMessage, e); } if (okToProceed) { super.okPressed(); } }