public void createFolder(
      CommandArgument argument, HttpServletRequest request, HttpServletResponse response) {

    Document doc = _createDocument();

    Node root =
        _createRoot(
            doc,
            argument.getCommand(),
            argument.getType(),
            argument.getCurrentFolder(),
            StringPool.BLANK);

    Element errorEl = doc.createElement("Error");

    root.appendChild(errorEl);

    String returnValue = "0";

    try {
      returnValue = createFolder(argument);
    } catch (FCKException fcke) {
      Throwable cause = fcke.getCause();

      returnValue = "110";

      if (cause != null) {
        String causeString = GetterUtil.getString(cause.toString());

        if (causeString.indexOf("DuplicateFolderNameException") != -1) {
          returnValue = "101";
        } else if (causeString.indexOf("FolderNameException") != -1) {
          returnValue = "102";
        } else if (causeString.indexOf("NoSuchGroupException") != -1) {
          returnValue = "103";
        } else {
          throw fcke;
        }
      }
    }

    errorEl.setAttribute("number", returnValue);

    _writeDocument(doc, response);
  }
  public void fileUpload(
      CommandArgument argument, HttpServletRequest request, HttpServletResponse response) {

    ServletFileUpload upload =
        new ServletFileUpload(
            new LiferayFileItemFactory(UploadServletRequestImpl.DEFAULT_TEMP_DIR));

    List<FileItem> items = null;

    try {
      items = upload.parseRequest(request);
    } catch (FileUploadException fue) {
      throw new FCKException(fue);
    }

    Map<String, Object> fields = new HashMap<String, Object>();

    for (FileItem item : items) {
      if (item.isFormField()) {
        fields.put(item.getFieldName(), item.getString());
      } else {
        fields.put(item.getFieldName(), item);
      }
    }

    DiskFileItem fileItem = (DiskFileItem) fields.get("NewFile");

    String fileName = StringUtil.replace(fileItem.getName(), "\\", "/");
    String[] fileNameArray = StringUtil.split(fileName, "/");
    fileName = fileNameArray[fileNameArray.length - 1];

    String extension = _getExtension(fileName);

    String returnValue = null;

    try {
      returnValue = fileUpload(argument, fileName, fileItem.getStoreLocation(), extension);
    } catch (FCKException fcke) {
      Throwable cause = fcke.getCause();

      returnValue = "203";

      if (cause != null) {
        String causeString = GetterUtil.getString(cause.toString());

        if ((causeString.indexOf("NoSuchFolderException") != -1)
            || (causeString.indexOf("NoSuchGroupException") != -1)) {

          returnValue = "204";
        } else if (causeString.indexOf("ImageNameException") != -1) {
          returnValue = "205";
        } else if (causeString.indexOf("FileNameException") != -1) {
          returnValue = "206";
        } else if (causeString.indexOf("PrincipalException") != -1) {
          returnValue = "207";
        } else {
          throw fcke;
        }
      }

      _writeUploadResponse(returnValue, response);
    }

    _writeUploadResponse(returnValue, response);
  }