* @param progress callback for showing messages\r
*/\r
void installTool(@NotNull NuGetTool tool, @NotNull ActionProgress progress);\r
-\r
- /**\r
- * Registers user-provided NuGet tool from given NuGetInstalledTool i\r
- * @param tool tool description to install\r
- * @param progress action progress callback\r
- */\r
- void registerCustomTool(@NotNull NuGetUserTool tool, @NotNull ActionProgress progress);\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.toolRegistry.impl;\r
+\r
+import jetbrains.buildServer.nuget.server.feed.reader.FeedConstants;\r
+import jetbrains.buildServer.nuget.server.feed.reader.FeedPackage;\r
+import jetbrains.buildServer.nuget.server.feed.reader.NuGetFeedReader;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.NuGetTool;\r
+import jetbrains.buildServer.util.CollectionsUtil;\r
+import jetbrains.buildServer.util.Converter;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.IOException;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 15.08.11 16:33\r
+ */\r
+public class AvailableToolsState {\r
+ private final NuGetFeedReader myReader;\r
+\r
+ public AvailableToolsState(@NotNull final NuGetFeedReader reader) {\r
+ myReader = reader;\r
+ }\r
+\r
+ public Collection<NuGetTool> getAvailable() {\r
+ try {\r
+ final Collection<FeedPackage> packages = myReader.queryPackageVersions(FeedConstants.FEED_URL, FeedConstants.NUGET_COMMANDLINE);\r
+ return CollectionsUtil.convertCollection(\r
+ packages,\r
+ new Converter<NuGetTool, FeedPackage>() {\r
+ public NuGetTool createFrom(@NotNull FeedPackage source) {\r
+ return new InstallableTool(source);\r
+ }\r
+ }\r
+ );\r
+\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ //TODO: handle exception\r
+ return Collections.emptyList();\r
+ }\r
+ }\r
+\r
+ private static class InstallableTool implements NuGetTool {\r
+ private final FeedPackage myPackage;\r
+\r
+ private InstallableTool(@NotNull final FeedPackage aPackage) {\r
+ myPackage = aPackage;\r
+ }\r
+\r
+ @NotNull\r
+ public String getId() {\r
+ return myPackage.getAtomId();\r
+ }\r
+\r
+ @NotNull\r
+ public String getVersion() {\r
+ return myPackage.getInfo().getVersion();\r
+ }\r
+\r
+ @NotNull\r
+ public FeedPackage getPackage() {\r
+ return myPackage;\r
+ }\r
+ }\r
+}\r
import java.io.File;\r
import java.util.Arrays;\r
import java.util.Collection;\r
+import java.util.List;\r
\r
/**\r
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
* Date: 11.08.11 1:07\r
*/\r
public class NuGetToolManagerImpl implements NuGetToolManager {\r
+ private final AvailableToolsState myAvailables;\r
+\r
+ public NuGetToolManagerImpl(AvailableToolsState availables) {\r
+ myAvailables = availables;\r
+ }\r
+\r
@NotNull\r
public Collection<NuGetInstalledTool> getInstalledTools() {\r
- return Arrays.<NuGetInstalledTool>asList(\r
- new NuGetInstalledTool() {\r
- @NotNull\r
- public File getPath() {\r
- return new File(".");\r
- }\r
+ return mockInstalledTools();\r
+ }\r
\r
- @NotNull\r
- public String getId() {\r
- return "i1";\r
- }\r
+ @NotNull\r
+ public Collection<NuGetInstallingTool> getInstallingTool() {\r
+ return mockInstallingTools();\r
+ }\r
\r
- @NotNull\r
- public String getVersion() {\r
- return "i1.2.3.5";\r
- }\r
- },\r
- new NuGetInstalledTool() {\r
- @NotNull\r
- public File getPath() {\r
- return new File(".");\r
- }\r
\r
- @NotNull\r
- public String getId() {\r
- return "i2";\r
- }\r
+ @NotNull\r
+ public Collection<NuGetTool> getAvailableTools() {\r
+ //This must be cached to make if work faster!\r
+ return myAvailables.getAvailable();\r
+ }\r
+\r
+\r
+ public void installTool(@NotNull NuGetTool tool, @NotNull ActionProgress progress) {\r
\r
- @NotNull\r
- public String getVersion() {\r
- return "i2.4.5.7";\r
- }\r
- }\r
- );\r
}\r
\r
- @NotNull\r
- public Collection<NuGetInstallingTool> getInstallingTool() {\r
+ private List<NuGetInstallingTool> mockInstallingTools() {\r
return Arrays.<NuGetInstallingTool>asList(\r
new NuGetInstallingTool() {\r
@NotNull\r
);\r
}\r
\r
- @NotNull\r
- public Collection<NuGetTool> getAvailableTools() {\r
- return Arrays.<NuGetTool>asList(\r
- new NuGetTool() {\r
+ private List<NuGetInstalledTool> mockInstalledTools() {\r
+ return Arrays.<NuGetInstalledTool>asList(\r
+ new NuGetInstalledTool() {\r
+ @NotNull\r
+ public File getPath() {\r
+ return new File(".");\r
+ }\r
+\r
@NotNull\r
public String getId() {\r
- return "a-1";\r
+ return "i1";\r
}\r
\r
@NotNull\r
public String getVersion() {\r
- return "a.3.5.6";\r
+ return "i1.2.3.5";\r
}\r
},\r
- new NuGetTool() {\r
+ new NuGetInstalledTool() {\r
+ @NotNull\r
+ public File getPath() {\r
+ return new File(".");\r
+ }\r
+\r
@NotNull\r
public String getId() {\r
- return "a-2";\r
+ return "i2";\r
}\r
\r
@NotNull\r
public String getVersion() {\r
- return "a2.5.6.6";\r
+ return "i2.4.5.7";\r
}\r
}\r
);\r
}\r
-\r
- public void installTool(@NotNull NuGetTool tool, @NotNull ActionProgress progress) {\r
-\r
- }\r
-\r
- public void registerCustomTool(@NotNull NuGetUserTool tool, @NotNull ActionProgress progress) {\r
-\r
- }\r
}\r