package org.jenkinsci.plugins.jenkinsreviewbot;

import hudson.Extension;
import hudson.model.StringParameterDefinition;
import hudson.model.StringParameterValue;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

import java.lang.reflect.Field;

/**
 * User: ymeymann
 * Date: 6/2/13 5:21 PM
 */
public class ReviewboardParameterDefinition extends StringParameterDefinition {

  @DataBoundConstructor
  public ReviewboardParameterDefinition() {
    super("review.url", "");
  }

  @Override
  public String getDescription() {
    return Messages.ReviewboardParameterDefinition_Description();
  }

  @Override
  public ReviewboardParameterValue createValue(StaplerRequest req, JSONObject jo) {
    return wrap((StringParameterValue) super.createValue(req, jo));
  }

  private ReviewboardParameterValue wrap(StringParameterValue rhs) {
    try {
      Field $value = StringParameterValue.class.getDeclaredField("value");
      $value.setAccessible(true);
      ReviewboardParameterValue v = new ReviewboardParameterValue(rhs.getName(), (String)$value.get(rhs));
      return v;
    } catch (NoSuchFieldException e) {
      throw new Error(e);
    } catch (IllegalAccessException e) {
      throw new Error(e);
    }
  }

  @Extension
  public static class DescriptorImpl extends StringParameterDefinition.DescriptorImpl {
    @Override
    public String getDisplayName() {
      return Messages.ReviewboardParameterDefinition_DisplayName();
    }
  }

}

@@ -63,24 +63,90 @@
 .Extension;%0A
+import hudson.cli.CLICommand;%0Aimport hudson.model.ParameterValue;%0A
 import hudso
@@ -176,24 +176,24 @@
 Definition;%0A
-
 import hudso
@@ -342,24 +342,52 @@
 erRequest;%0A%0A
+import java.io.IOException;%0A
 import java.
@@ -683,24 +683,24 @@
 ription() %7B%0A
-
     return M
@@ -750,32 +750,155 @@
 ription();%0A  %7D%0A%0A
+  public ParameterValue createValue(String value) %7B%0A    return wrap((StringParameterValue) super.createValue(value));%0A  %7D%0A%0A
   @Override%0A  pu

Fix remote invokation