X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.server%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fweb%2Fmvc%2Fprovisioning%2FListModularDistributions.java;fp=runtime%2Forg.argeo.slc.server%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fweb%2Fmvc%2Fprovisioning%2FListModularDistributions.java;h=0000000000000000000000000000000000000000;hb=651d33e13bfa9a7b46464be412023ee747e612e8;hp=f0523dda4c22a24f9899736cc4d16adbdc0ae5cd;hpb=868102c0f0220e12eca836b6ec9b3a2b9a3441e4;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/provisioning/ListModularDistributions.java b/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/provisioning/ListModularDistributions.java deleted file mode 100644 index f0523dda4..000000000 --- a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/provisioning/ListModularDistributions.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.web.mvc.provisioning; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.argeo.slc.BasicNameVersion; -import org.argeo.slc.NameVersion; -import org.argeo.slc.build.BuildConstants; -import org.argeo.slc.build.ModularDistribution; -import org.argeo.slc.msg.ObjectList; -import org.argeo.slc.msg.build.ModularDistributionDescriptor; -import org.argeo.slc.web.mvc.AbstractServiceController; -import org.springframework.web.servlet.ModelAndView; - -/** List of distributions. */ -public class ListModularDistributions extends AbstractServiceController - implements Comparator { - private Set modularDistributions; - - private String provisioningServletPath = "/dist"; - - @Override - protected void handleServiceRequest(HttpServletRequest request, - HttpServletResponse response, ModelAndView modelAndView) - throws Exception { - - String baseUrl = "http://" + request.getServerName() + ":" - + request.getServerPort() + request.getContextPath() - + provisioningServletPath + "/"; - - SortedSet descriptors = new TreeSet( - this); - - Set names = new HashSet(); - Set namesRelease = new HashSet(); - - // Scan distributions - for (Iterator it = modularDistributions.iterator(); it - .hasNext();) { - ModularDistribution md = it.next(); - ModularDistributionDescriptor mdd = fromNameVersion(baseUrl, md); - - descriptors.add(mdd); - names.add(mdd.getName()); - if (!md.getVersion().contains(BuildConstants.SNAPSHOT)) - namesRelease.add(mdd.getName()); - } - - // Add LATESTs and RELEASEs - for (String name : names) - descriptors.add(fromNameVersion(baseUrl, new BasicNameVersion(name, - BuildConstants.LATEST))); - for (String name : namesRelease) - descriptors.add(fromNameVersion(baseUrl, new BasicNameVersion(name, - BuildConstants.RELEASE))); - - modelAndView.addObject(new ObjectList(descriptors)); - } - - public void setModularDistributions( - Set modularDistributions) { - this.modularDistributions = modularDistributions; - } - - public void setProvisioningServletPath(String provisioningServletPath) { - this.provisioningServletPath = provisioningServletPath; - } - - protected ModularDistributionDescriptor fromNameVersion(String baseUrl, - NameVersion md) { - String moduleBase = baseUrl + md.getName() + "/" + md.getVersion() - + "/"; - ModularDistributionDescriptor mdd = new ModularDistributionDescriptor(); - mdd.setName(md.getName()); - mdd.setVersion(md.getVersion()); - - mdd.getModulesDescriptors().put("modularDistribution", - moduleBase + "modularDistribution"); - mdd.getModulesDescriptors().put("eclipse", moduleBase + "site.xml"); - return mdd; - - } - - /** RELEASEs first, then LATESTs, then version */ - public int compare(ModularDistributionDescriptor mdd1, - ModularDistributionDescriptor mdd2) { - final int BEFORE = -1; - final int AFTER = 1; - - String n1 = mdd1.getName(); - String v1 = mdd1.getVersion(); - String n2 = mdd2.getName(); - String v2 = mdd2.getVersion(); - - if (v1.equals(BuildConstants.RELEASE)) - if (v2.equals(BuildConstants.RELEASE)) - return n1.compareTo(n2); - else - return BEFORE; - else if (v2.equals(BuildConstants.RELEASE)) - return AFTER;// we know 1 not RELEASE - else if (v1.equals(BuildConstants.LATEST)) - if (v2.equals(BuildConstants.LATEST)) - return n1.compareTo(n2); - else - return BEFORE; - else if (v2.equals(BuildConstants.LATEST)) - return AFTER;// we know 1 not LATEST or RELEASE - else if (n1.equals(n2)) - return v1.compareTo(v2); - else - return n1.compareTo(n2); - } - -}