<%@ include file="/include-internal.jsp" %>\r
<jsp:useBean id="errorText" scope="request" type="java.lang.String"/>\r
<div id="nugetInstallFormResreshInner">\r
- <div class="error">\r
- <p>Failed to fetch latest NuGet packages from default feed.</p>\r
- <p><c:out value="${errorText}"/></p>\r
- <p>Press <a href="#" onclick="BS.NuGet.Tools.InstallPopup.refreshForm()">Refresh</a> to try again.</p>\r
- <script type="text/javascript">\r
- BS.NuGet.Tools.InstallPopup.disableSubmit();\r
- </script>\r
+ <div class="error" style="margin-left: 0">\r
+ <div>\r
+ Failed to fetch latest NuGet packages from default feed.\r
+ </div>\r
+ <div>\r
+ <c:out value="${errorText}"/>\r
+ </div>\r
</div>\r
</div>
\ No newline at end of file
+++ /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
-<%@ include file="/include-internal.jsp" %>\r
-<div id="nugetInstallFormResreshInner">\r
- <forms:saving style="float: left; display:block;"/>\r
- Discovering available NuGet.exe Command Line versions\r
- <script type="text/javascript">\r
- BS.NuGet.Tools.InstallPopup.disableSubmit();\r
- </script>\r
-</div>\r
-\r
<c:choose>\r
<c:when test="${fn:length(available) eq 0}">\r
No other NuGet.exe Command Line packages available\r
- <script type="text/javascript">\r
- BS.NuGet.Tools.InstallPopup.disableSubmit();\r
- </script>\r
</c:when>\r
<c:otherwise>\r
<table class="runnerFormTable">\r
</table>\r
</c:otherwise>\r
</c:choose>\r
-</div>
\ No newline at end of file
+ <script type="text/javascript">\r
+ BS.NuGet.Tools.InstallPopup.enableSubmit();\r
+ </script>\r
+</div>\r
+\r
},\r
\r
disableSubmit : function() {\r
- $('installNuGetApplyButton').disabled = true;\r
+ $('installNuGetApplyButton').disabled = 'disabled';\r
},\r
\r
enableSubmit : function() {\r
- $('installNuGetApplyButton').disabled = false;\r
+ $('installNuGetApplyButton').disabled = '';\r
},\r
\r
- refreshForm : function() {\r
- var that = this;\r
- that.enableSubmit();\r
- $('nugetInstallFormResresh').refresh("nugetInstallLinkSaving", null, function() {\r
- that.showCentered();\r
+ refreshForm : function(fresh) {\r
+ this.disableSubmit();\r
+ BS.Util.hide($('nugetInstallFormResresh'));\r
+ BS.Util.show($('nugetInstallFormLoading'));\r
+ $('nugetInstallFormResresh').refresh("nugetInstallLinkSaving", fresh ? "fresh=1": "", function() {\r
+ BS.Util.hide($('nugetInstallFormLoading'));\r
+ BS.Util.show($('nugetInstallFormResresh'));\r
+ BS.NuGet.Tools.InstallPopup.showCentered();\r
});\r
return false;\r
},\r
if (!wereErrors) {\r
BS.NuGet.Tools.refreshPackagesList();\r
form.close();\r
+ } else {\r
+ BS.Util.reenableForm(form.formElement());\r
}\r
}\r
}));\r
+ return false;\r
}\r
}))\r
};\r
action="${actualInstallerUrl}"\r
closeCommand="BS.NuGet.Tools.InstallPopup.close();"\r
saveCommand="BS.NuGet.Tools.InstallPopup.save();">\r
+ <div id="nugetInstallFormLoading">\r
+ <forms:saving style="float: left; display:block;"/>\r
+ Discovering available NuGet.exe Command Line versions\r
+ </div>\r
+\r
<bs:refreshable containerId="nugetInstallFormResresh" pageUrl="${actualInstallerUrl}">\r
- <jsp:include page="installTool-loading.jsp"/>\r
+\r
</bs:refreshable>\r
\r
<div class="popupSaveButtonsBlock">\r
<a href="javascript://" onclick="BS.NuGet.Tools.InstallPopup.close();" class="cancel">Cancel</a>\r
- <input class="submitButton" type="button" value="Install" id="installNuGetApplyButton" onclick="BS.NuGet.Tools.InstallPopup.save();"/>\r
+ <input class="submitButton" type="submit" value="Install" id="installNuGetApplyButton" />\r
+ <a href="javascript://" onclick="BS.NuGet.Tools.InstallPopup.refreshForm(true);" class="cancel">Refresh</a>\r
<forms:saving id="installNuGetApplyProgress"/>\r
<br clear="all"/>\r
</div>\r
-</bs:modalDialog>
\ No newline at end of file
+</bs:modalDialog>\r
+\r
+<script type="text/javascript">\r
+ BS.NuGet.Tools.InstallPopup.disableSubmit();\r
+</script>\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;\r
+\r
+/**\r
+* Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+* Date: 15.08.11 19:10\r
+*/\r
+public class FetchException extends Exception {\r
+ public FetchException(String message, Throwable cause) {\r
+ super(message, cause);\r
+ }\r
+}\r
Collection<NuGetInstallingTool> getInstallingTool();\r
\r
/**\r
+ * @param policy kind of packages to return\r
* @return fetches the full list of available and supported nuget tools\r
+ * @throws FetchException on fetch error if it was called\r
*/\r
@NotNull\r
- Collection<NuGetTool> getAvailableTools();\r
+ Collection<NuGetTool> getAvailableTools(@NotNull final ToolsPolicy policy) throws FetchException;\r
\r
/**\r
* Downloads and installs nuget tools for both server and agent\r
* @param toolId tool id for tool to install\r
*/\r
void installTool(@NotNull String toolId);\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.toolRegistry;\r
+\r
+/**\r
+* Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+* Date: 15.08.11 19:12\r
+*/\r
+public enum ToolsPolicy {\r
+ ReturnCached,\r
+ FetchNew\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.FetchException;\r
import jetbrains.buildServer.nuget.server.toolRegistry.NuGetTool;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.ToolsPolicy;\r
import jetbrains.buildServer.util.CollectionsUtil;\r
import jetbrains.buildServer.util.Converter;\r
import jetbrains.buildServer.util.TimeService;\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
}\r
\r
@NotNull\r
- public Collection<NuGetTool> getAvailable() {\r
+ public Collection<NuGetTool> getAvailable(ToolsPolicy policy) throws FetchException {\r
Collection<NuGetTool> nuGetTools = myTools;\r
- if (nuGetTools == null || lastRequest + TIMEOUT < myTime.now()) {\r
+ if (policy == ToolsPolicy.FetchNew\r
+ || nuGetTools == null\r
+ || lastRequest + TIMEOUT < myTime.now()) {\r
+ myTools = null;\r
myTools = nuGetTools = fetchAvailable();\r
lastRequest = myTime.now();\r
}\r
return nuGetTools;\r
}\r
\r
- private Collection<NuGetTool> fetchAvailable() {\r
+ private Collection<NuGetTool> fetchAvailable() throws FetchException {\r
try {\r
final Collection<FeedPackage> packages = myReader.queryPackageVersions(FeedConstants.FEED_URL, FeedConstants.NUGET_COMMANDLINE);\r
return CollectionsUtil.filterAndConvertCollection(\r
);\r
\r
} catch (IOException e) {\r
- e.printStackTrace();\r
- //TODO: handle exception\r
- return Collections.emptyList();\r
+ throw new FetchException(e.getMessage(), e);\r
}\r
}\r
\r
return myPackage;\r
}\r
}\r
+\r
}\r
return mockInstallingTools();\r
}\r
\r
-\r
@NotNull\r
- public Collection<NuGetTool> getAvailableTools() {\r
+ public Collection<NuGetTool> getAvailableTools(@NotNull ToolsPolicy policy) throws FetchException {\r
//This must be cached to make if work faster!\r
- return myAvailables.getAvailable();\r
+ return myAvailables.getAvailable(policy);\r
}\r
\r
public void installTool(@NotNull String toolId) {\r
import jetbrains.buildServer.controllers.*;\r
import jetbrains.buildServer.nuget.server.toolRegistry.NuGetTool;\r
import jetbrains.buildServer.nuget.server.toolRegistry.NuGetToolManager;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.ToolsPolicy;\r
import jetbrains.buildServer.serverSide.auth.AccessDeniedException;\r
import jetbrains.buildServer.serverSide.auth.AuthorityHolder;\r
import jetbrains.buildServer.util.StringUtil;\r
return myPath;\r
}\r
\r
-\r
@Override\r
protected ModelAndView doGet(HttpServletRequest request, HttpServletResponse response) {\r
final Collection<NuGetTool> availableTools = new ArrayList<NuGetTool>();\r
\r
+ final ToolsPolicy pol =\r
+ StringUtil.isEmptyOrSpaces(request.getParameter("fresh"))\r
+ ? ToolsPolicy.ReturnCached\r
+ : ToolsPolicy.FetchNew;\r
+\r
try {\r
- availableTools.addAll(myToolsManager.getAvailableTools());\r
+ availableTools.addAll(myToolsManager.getAvailableTools(pol));\r
} catch (Exception e) {\r
ModelAndView mv = new ModelAndView(myDescriptor.getPluginResourcesPath("tool/installTool-error.jsp"));\r
mv.getModel().put("errorText", e.getMessage());\r