package jetbrains.buildServer.nuget.server.trigger;

import jetbrains.buildServer.buildTriggers.*;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import org.jetbrains.annotations.NotNull;

/**
 * @author Eugene Petrenko (eugene.petrenko@gmail.com)
 *         Date: 03.05.11 15:25
 */
public class NuGetSimpleTrigger extends BuildTriggerService {
  private final PluginDescriptor myDescriptor;

  public NuGetSimpleTrigger(@NotNull final PluginDescriptor descriptor) {
    myDescriptor = descriptor;
  }

  @NotNull
  @Override
  public String getName() {
    return TriggerConstants.TRIGGER_ID;
  }

  @NotNull
  @Override
  public String getDisplayName() {
    return "NuGet Dependency Trigger";
  }

  @NotNull
  @Override
  public String describeTrigger(@NotNull final BuildTriggerDescriptor trigger) {
    return "Triggers build on NuGet dependency change";
  }

  @NotNull
  @Override
  public BuildTriggeringPolicy getBuildTriggeringPolicy() {
    return new PolledBuildTrigger() {
      @Override
      public void triggerBuild(@NotNull final PolledTriggerContext context) throws BuildTriggerException {
      }
    };
  }

  @Override
  public String getEditParametersUrl() {
    return myDescriptor.getPluginResourcesPath("trigger/editSimpleTrigger.jsp");
  }
}

@@ -128,79 +128,330 @@
 ver.
-web.openapi.PluginDescriptor;%0D%0Aimport org.jetbrains.annotations.NotNull
+serverSide.InvalidProperty;%0D%0Aimport jetbrains.buildServer.serverSide.PropertiesProcessor;%0D%0Aimport jetbrains.buildServer.util.StringUtil;%0D%0Aimport jetbrains.buildServer.web.openapi.PluginDescriptor;%0D%0Aimport org.jetbrains.annotations.NotNull;%0D%0A%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.Collection;%0D%0Aimport java.util.Map
 ;%0D%0A%0D
@@ -1432,16 +1432,827 @@
 %0A  %7D%0D%0A%0D%0A
+  @Override%0D%0A  public boolean isMultipleTriggersPerBuildTypeAllowed() %7B%0D%0A    return true;%0D%0A  %7D%0D%0A%0D%0A  @Override%0D%0A  public PropertiesProcessor getTriggerPropertiesProcessor() %7B%0D%0A    return new PropertiesProcessor() %7B%0D%0A      public Collection%3CInvalidProperty%3E process(Map%3CString, String%3E properties) %7B%0D%0A        Collection%3CInvalidProperty%3E err = new ArrayList%3CInvalidProperty%3E();%0D%0A%0D%0A        if (StringUtil.isEmptyOrSpaces(properties.get(TriggerConstants.SOURCE))) %7B%0D%0A          err.add(new InvalidProperty(TriggerConstants.SOURCE, %22Source must be specified%22));%0D%0A        %7D%0D%0A%0D%0A        if (StringUtil.isEmptyOrSpaces(properties.get(TriggerConstants.PACKAGE))) %7B%0D%0A          err.add(new InvalidProperty(TriggerConstants.PACKAGE, %22Package Id must be specified%22));%0D%0A        %7D%0D%0A%0D%0A        return err;%0D%0A      %7D%0D%0A    %7D;%0D%0A  %7D%0D%0A%0D%0A
   @Overr

support validation