--- /dev/null
+/*\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.publish;\r
+\r
+import jetbrains.buildServer.nuget.common.DotNetConstants;\r
+import jetbrains.buildServer.nuget.common.PackagesConstants;\r
+import jetbrains.buildServer.requirements.Requirement;\r
+import jetbrains.buildServer.requirements.RequirementType;\r
+import jetbrains.buildServer.serverSide.InvalidProperty;\r
+import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
+import jetbrains.buildServer.serverSide.RunType;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.*;\r
+\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_API_KEY;\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_PATH;\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_PUBLISH_FILES;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 21.07.11 14:15\r
+ */\r
+public class PublishRunType extends RunType {\r
+ private final PluginDescriptor myDescriptor;\r
+\r
+ public PublishRunType(@NotNull final PluginDescriptor descriptor) {\r
+ myDescriptor = descriptor;\r
+ }\r
+\r
+ @NotNull\r
+ @Override\r
+ public String getType() {\r
+ return PackagesConstants.PUBLISH_RUN_TYPE;\r
+ }\r
+\r
+ @Override\r
+ public String getDisplayName() {\r
+ return "NuGet Publish Packages";\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "Pushes and publishes NuGet package to a given feed";\r
+ }\r
+\r
+ @Override\r
+ public PropertiesProcessor getRunnerPropertiesProcessor() {\r
+ return new PropertiesProcessor() {\r
+ public Collection<InvalidProperty> process(Map<String, String> properties) {\r
+ final List<InvalidProperty> checks = new ArrayList<InvalidProperty>();\r
+\r
+ if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_PATH))) {\r
+ checks.add(new InvalidProperty(NUGET_PATH, "Path to nuget.exe must be specified"));\r
+ }\r
+\r
+ if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_API_KEY))) {\r
+ checks.add(new InvalidProperty(NUGET_API_KEY, "API key must be specified"));\r
+ }\r
+\r
+ if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_PUBLISH_FILES))) {\r
+ checks.add(new InvalidProperty(NUGET_API_KEY, "Specify at least one package to pusblish"));\r
+ }\r
+\r
+ return checks;\r
+ }\r
+ };\r
+ }\r
+\r
+ @Override\r
+ public String getEditRunnerParamsJspFilePath() {\r
+ return myDescriptor.getPluginResourcesPath("publish/editPublish.jsp");\r
+ }\r
+\r
+ @Override\r
+ public String getViewRunnerParamsJspFilePath() {\r
+ return myDescriptor.getPluginResourcesPath("publish/viewPublish.jsp");\r
+ }\r
+\r
+ @Override\r
+ public Map<String, String> getDefaultRunnerProperties() {\r
+ return Collections.emptyMap();\r
+ }\r
+\r
+ @Override\r
+ public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
+ List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
+ list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
+ return list;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\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.publish;\r
+\r
+import jetbrains.buildServer.serverSide.RunTypeRegistry;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 21.07.11 14:20\r
+ */\r
+public class PublishRunTypeRegistrar {\r
+ public PublishRunTypeRegistrar(@NotNull final PublishRunType rt,\r
+ @NotNull final RunTypeRegistry reg) {\r
+ reg.registerRunType(rt);\r
+ }\r
+}\r