/**
   * Creates the view URL from the given workflow action.
   *
   * @param action a workflow action
   * @return the view URL
   * @throws SystemException if an error occurs while encoding the URL
   */
  private String getViewUrl(WorkflowActionVO action) throws SystemException {
    if (!action.hasView()) return "";

    StringBuffer buffer = new StringBuffer(action.getView());
    if (containsQuestionMark(action.getView())) buffer.append('&');
    else buffer.append('?');

    return buffer
        .append("workflowId=")
        .append(getWorkflowId())
        .append("&actionId=")
        .append(action.getId())
        .append("&returnAddress=")
        .append(getReturnAddress())
        .append("&finalReturnAddress=")
        .append(getFinalReturnAddress())
        .append('&')
        .append(getRequest().getQueryString())
        .toString();
  }
  /** Gets a description div of a workflow */
  public String doGetAvailableWorkflowProperties() throws Exception {
    StringBuffer sb = new StringBuffer();

    String workflowName = getRequest().getParameter("workflowName");

    try {
      List availableWorkflowVOList = controller.getAvailableWorkflowVOList(getInfoGluePrincipal());

      Iterator availableWorkflowVOListIterator = availableWorkflowVOList.iterator();
      while (availableWorkflowVOListIterator.hasNext()) {
        WorkflowVO availableWorkflowVO = (WorkflowVO) availableWorkflowVOListIterator.next();
        if (workflowName.equals(availableWorkflowVO.getName())) {
          sb.append(
              "<div id=\"availableWorkflowDetailsProperties\" class=\"propertiesDiv\" style=\"z-index: 10;\">");
          sb.append(
              "	<div id=\"availableWorkflowDetailsPropertiesHandle\" class=\"propertiesDivHandle\">");
          sb.append(
              "		<div id=\"propertiesDivLeftHandle\" class=\"propertiesDivLeftHandle\">"
                  + availableWorkflowVO.getName()
                  + "</div><div id=\"propertiesDivRightHandle\" class=\"propertiesDivRightHandle\"><a href=\"javascript:hideDiv('availableWorkflowDetailsProperties');\" class=\"white\">close</a></div>");
          sb.append("	</div>");
          sb.append(
              "	<div id=\"availableWorkflowDetailsPropertiesBody\" class=\"propertiesDivBody\">");
          sb.append("		<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%\">");

          Iterator workflowStepVOIterator = availableWorkflowVO.getDeclaredSteps().iterator();
          while (workflowStepVOIterator.hasNext()) {
            WorkflowStepVO workflowStepVO = (WorkflowStepVO) workflowStepVOIterator.next();

            sb.append("		<tr style=\"background-color: white;\">");
            sb.append("			<td>" + workflowStepVO.getName() + "</td>");
            sb.append(
                "			<td>"
                    + (workflowStepVO.getOwner() != null
                        ? workflowStepVO.getOwner()
                        : "Not specified")
                    + "</td>");
            sb.append("		</tr>");

            Iterator workflowActionVOIterator = workflowStepVO.getActions().iterator();
            while (workflowActionVOIterator.hasNext()) {
              WorkflowActionVO workflowActionVO =
                  (WorkflowActionVO) workflowActionVOIterator.next();

              sb.append("<tr style=\"background-color: #eeeeee;\">");
              sb.append(
                  "	<td style=\"padding-left: 20px; font-size:10px;\">"
                      + workflowActionVO.getName()
                      + "</td>");
              sb.append(
                  "		<td style=\"padding-left: 20px; font-size:10px;\"><!--"
                      + workflowActionVO.getView()
                      + "--></td>");
              sb.append("	</tr>");
            }
          }
          sb.append("		</table>");
          sb.append("	</div>");
          sb.append("</div>");
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    this.getResponse().setContentType("text/plain");
    this.getResponse().getWriter().println(sb.toString());

    return NONE;
  }