support validation
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 12 Jul 2011 11:58:44 +0000 (15:58 +0400)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Wed, 13 Jul 2011 16:50:47 +0000 (20:50 +0400)
nuget-server/src/jetbrains/buildServer/nuget/server/trigger/NuGetSimpleTrigger.java

index ad56245055af15007dca86ddc1c1a50564579b33..edb387f8054d26df0d764f306811ec58e3273ff8 100644 (file)
@@ -1,9 +1,16 @@
 package jetbrains.buildServer.nuget.server.trigger;\r
 \r
 import jetbrains.buildServer.buildTriggers.*;\r
+import jetbrains.buildServer.serverSide.InvalidProperty;\r
+import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
+import jetbrains.buildServer.util.StringUtil;\r
 import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
 /**\r
  * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
  *         Date: 03.05.11 15:25\r
@@ -43,6 +50,30 @@ public class NuGetSimpleTrigger extends BuildTriggerService {
     };\r
   }\r
 \r
+  @Override\r
+  public boolean isMultipleTriggersPerBuildTypeAllowed() {\r
+    return true;\r
+  }\r
+\r
+  @Override\r
+  public PropertiesProcessor getTriggerPropertiesProcessor() {\r
+    return new PropertiesProcessor() {\r
+      public Collection<InvalidProperty> process(Map<String, String> properties) {\r
+        Collection<InvalidProperty> err = new ArrayList<InvalidProperty>();\r
+\r
+        if (StringUtil.isEmptyOrSpaces(properties.get(TriggerConstants.SOURCE))) {\r
+          err.add(new InvalidProperty(TriggerConstants.SOURCE, "Source must be specified"));\r
+        }\r
+\r
+        if (StringUtil.isEmptyOrSpaces(properties.get(TriggerConstants.PACKAGE))) {\r
+          err.add(new InvalidProperty(TriggerConstants.PACKAGE, "Package Id must be specified"));\r
+        }\r
+\r
+        return err;\r
+      }\r
+    };\r
+  }\r
+\r
   @Override\r
   public String getEditParametersUrl() {\r
     return myDescriptor.getPluginResourcesPath("trigger/editSimpleTrigger.jsp");\r