resolve merge conflicts
authorEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 14 Jul 2011 11:10:49 +0000 (15:10 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 14 Jul 2011 11:10:49 +0000 (15:10 +0400)
README
nuget-server/src/jetbrains/buildServer/nuget/server/trigger/NuGetTriggerPolicy.java [new file with mode: 0644]

diff --git a/README b/README
index 4d5e47823187fd740bf320501de2185dead6f83a..c1d6ed0d2e7fa2d83e531e6037566ed7c58ce938 100644 (file)
--- a/README
+++ b/README
@@ -12,4 +12,4 @@ API gaps:
  - Reuse ComposideBuildProcess and DelegatingBuildProcess\r
  - Use XmlXppAbstractParser#parse(InputSream)\r
  - Consider reuseing of Maven build trigger/project models\r
- - Make server-side PluginDescription contain getPluginRoot() to avoid cast to PluginInfo
\ No newline at end of file
+ - Make server-side PluginDescription contain getPluginRoot() to avoid cast to PluginInfo
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/trigger/NuGetTriggerPolicy.java b/nuget-server/src/jetbrains/buildServer/nuget/server/trigger/NuGetTriggerPolicy.java
new file mode 100644 (file)
index 0000000..414796f
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.server.trigger;\r
+\r
+import jetbrains.buildServer.buildTriggers.BuildTriggerException;\r
+import jetbrains.buildServer.buildTriggers.PolledBuildTrigger;\r
+import jetbrains.buildServer.buildTriggers.PolledTriggerContext;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.concurrent.*;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 12.07.11 23:29\r
+ */\r
+public class NuGetTriggerPolicy extends PolledBuildTrigger{\r
+  private final ExecutorService myExecutor;\r
+  private Future<Boolean> myUpdateRequired;\r
+\r
+  public NuGetTriggerPolicy(@NotNull final ExecutorService executor) {\r
+    myExecutor = executor;\r
+  }\r
+\r
+  @Override\r
+  public synchronized void triggerBuild(@NotNull PolledTriggerContext context) throws BuildTriggerException {\r
+    if (myUpdateRequired == null) {\r
+      myUpdateRequired = myExecutor.submit(createUpdateTask());\r
+    }\r
+\r
+    if (!myUpdateRequired.isDone()) return;\r
+\r
+    Boolean result;\r
+    try {\r
+      result = myUpdateRequired.get();\r
+    } catch (InterruptedException e) {\r
+      return;\r
+    } catch (ExecutionException e) {\r
+      Throwable cause = e.getCause();\r
+      throw new BuildTriggerException(cause.getMessage(), cause);\r
+    } finally {\r
+      myUpdateRequired = null;\r
+    }\r
+\r
+    if (Boolean.TRUE.equals(result)) {\r
+      String packageName = context.getTriggerDescriptor().getProperties().get(TriggerConstants.PACKAGE);\r
+      context.getBuildType().addToQueue("NuGet Package " + packageName + " updated");\r
+    }\r
+  }\r
+\r
+  private Callable<Boolean> createUpdateTask() {\r
+    return new Callable<Boolean>() {\r
+      public Boolean call() throws Exception {\r
+        return null;\r
+      }\r
+    };\r
+  }\r
+\r
+\r
+}\r