/**
  * 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;
 }
コード例 #2
0
  /**
   * 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;
    boolean isDash = false;
    WindowsAzureEndpointType oldType = waEndpt.getEndPointType();
    WindowsAzureEndpoint debugEndpt = waRole.getDebuggingEndpoint();
    WindowsAzureEndpoint stickyEndpt = waRole.getSessionAffinityInputEndpoint();
    WindowsAzureEndpoint stickyIntEndpt = waRole.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();
    }

    WindowsAzureEndpointType newType = (WindowsAzureEndpointType) comboType.getSelectedItem();
    if (newType.equals(WindowsAzureEndpointType.InstanceInput)
        || newType.equals(WindowsAzureEndpointType.Internal)) {
      isDash =
          WAEndpointDialogUtilMethods.isDashPresent(
              newType,
              txtPrivatePort.getText(),
              txtPrivatePortRangeEnd.getText(),
              txtPublicPort.getText(),
              txtPublicPortRangeEnd.getText());
    }
    if (isDash) {
      PluginUtil.displayErrorDialog(message("dlgInvldPort"), message("portRangeErrMsg"));
      retVal = false;
    } else {
      // Check for valid range 1 to 65535
      if (WAEndpointDialogUtilMethods.isValidPortRange(
          newType,
          txtPrivatePort.getText(),
          txtPrivatePortRangeEnd.getText(),
          txtPublicPort.getText(),
          txtPublicPortRangeEnd.getText())) {
        // validate ports
        String publicPort =
            WAEndpointDialogUtilMethods.combinePublicPortRange(
                txtPublicPort.getText(),
                txtPublicPortRangeEnd.getText(),
                comboType.getSelectedItem().toString());
        String privatePort =
            WAEndpointDialogUtilMethods.combinePrivatePortRange(
                txtPrivatePort.getText(),
                txtPrivatePortRangeEnd.getText(),
                comboType.getSelectedItem().toString());
        if (privatePort.equalsIgnoreCase(AUTO)) {
          privatePort = null;
        }

        boolean isValidendpoint =
            waRole.isValidEndpoint(oldEndptName, newType, privatePort, publicPort);
        if (isValidendpoint) {
          if (oldEndptName.equalsIgnoreCase(dbgEndptName)) {
            retVal = handleChangeForDebugEndpt(oldType, privatePort);
          }
          /** Disables the session affinity if endpoint's type is changed to 'Internal'. */
          if (oldEndptName.equalsIgnoreCase(stcEndptName)
              || oldEndptName.equalsIgnoreCase(stcIntEndptName)) {
            retVal = false;
          }
          if (retVal) {
            // set the new values in the endpoint object.
            waEndpt.setEndPointType((WindowsAzureEndpointType) comboType.getSelectedItem());
            waEndpt.setName(txtName.getText());
            /*
             * Type is Input or Instance then
             * set public port as well as private port.
             */
            if (comboType.getSelectedItem() == WindowsAzureEndpointType.Input
                || comboType.getSelectedItem() == WindowsAzureEndpointType.InstanceInput) {
              waEndpt.setPort(publicPort);
            }
            /*
             * Type is Internal then
             * set private port only.
             */
            waEndpt.setPrivatePort(privatePort);
          }
        } else {
          PluginUtil.displayErrorDialog(message("dlgInvldPort"), message("dlgPortInUse"));
          retVal = false;
        }
      } else {
        PluginUtil.displayErrorDialog(message("dlgInvldPort"), message("rngErrMsg"));
        retVal = false;
      }
    }
    return retVal;
  }
  private void init() {
    try {
      WindowsAzureEndpoint endPt = waRole.getDebuggingEndpoint();
      if (endPt == null) {
        debugCheck.setSelected(false);
        comboEndPoint.removeAllItems(); // todo: ???
        makeAllDisable();
      } else {
        populateEndPointList();
        comboEndPoint.setSelectedItem(
            String.format(
                message("dbgEndPtStr"), endPt.getName(), endPt.getPort(), endPt.getPrivatePort()));
      }
    } catch (Exception e) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e);
    }
    isDebugChecked = false;
    try {
      isDebugChecked = waRole.getDebuggingEndpoint() != null;
    } catch (Exception ex) {
      // As getTitle() is also showing the error message if any exception
      // occurs in role.getDebuggingEndpoint(), so only logging
      // the exception. getTitle() gets called every time this page is
      // selected but createContents() is called only once while creating
      // the page.
      log(message("dlgDbgErr"), ex);
    }
    debugCheck.setSelected(isDebugChecked);
    debugCheck.addItemListener(createDebugCheckListener());
    try {
      populateEndPointList();
    } catch (WindowsAzureInvalidProjectOperationException e1) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e1);
    }
    comboEndPoint.addItemListener(createComboEndPointListener());

    try {
      if (isDebugChecked) {
        jvmCheck.setSelected(waRole.getStartSuspended());
      } else {
        jvmCheck.setSelected(false);
      }

    } catch (WindowsAzureInvalidProjectOperationException e2) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e2);
    }
    jvmCheck.addItemListener(createJvmCheckListener());
    createDebug.addActionListener(createCreateDebugListener());

    try {
      if (isDebugChecked) {
        WindowsAzureEndpoint endPt = waRole.getDebuggingEndpoint();
        comboEndPoint.setSelectedItem(
            String.format(
                message("dbgEndPtStr"), endPt.getName(), endPt.getPort(), endPt.getPrivatePort()));
      } else {
        makeAllDisable();
      }
    } catch (WindowsAzureInvalidProjectOperationException e1) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e1);
    }
    if (debugCheck.isSelected() && comboEndPoint.getSelectedItem().equals("")) {
      //            setValid(false);
    }
  }