2 * Copyright (C) 2007-2012 Mathieu Baudier
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.web
.mvc
.provisioning
;
18 import java
.io
.IOException
;
19 import java
.io
.Writer
;
20 import java
.util
.Iterator
;
23 import javax
.servlet
.ServletException
;
24 import javax
.servlet
.http
.HttpServletRequest
;
25 import javax
.servlet
.http
.HttpServletResponse
;
27 import org
.argeo
.slc
.build
.ModularDistribution
;
28 import org
.springframework
.web
.HttpRequestHandler
;
30 /** List of distributions. */
31 public class AvailableDistributions
implements HttpRequestHandler
{
32 private Set
<ModularDistribution
> modularDistributions
;
34 public void handleRequest(HttpServletRequest request
,
35 HttpServletResponse response
) throws ServletException
, IOException
{
36 response
.setContentType("text/html");
38 String baseUrl
= "http://" + request
.getServerName() + ":"
39 + request
.getServerPort() + request
.getContextPath()
40 + request
.getServletPath() + "/";
42 Writer out
= response
.getWriter();
44 out
.write("<h1>Distributions</h1>");
45 for (Iterator
<ModularDistribution
> it
= modularDistributions
.iterator(); it
47 ModularDistribution md
= it
.next();
48 out
.write("<h2>" + md
+ "</h2>");
49 out
.write("Modules: ");
50 String moduleBase
= baseUrl
+ md
.getName() + "/" + md
.getVersion()
53 String modulesListHtml
= moduleBase
+ "modules.html";
54 out
.write(" <a href=\"" + modulesListHtml
+ "\">html</a>");
56 String modulesListPlain
= moduleBase
+ "modules";
57 out
.write(" <a href=\"" + modulesListPlain
+ "\">plain</a>");
59 String modulesListOsgiBoot
= moduleBase
+ "osgiBoot";
60 out
.write(" <a href=\"" + modulesListOsgiBoot
+ "\">osgiBoot</a>");
64 out
.write("Eclipse update site: ");
65 String updateSiteUrl
= baseUrl
+ md
.getName() + "/"
66 + md
.getVersion() + "/site.xml";
67 out
.write("<a href=\"" + updateSiteUrl
+ "\">" + updateSiteUrl
72 public void setModularDistributions(
73 Set
<ModularDistribution
> modularDistributions
) {
74 this.modularDistributions
= modularDistributions
;