[Yanel-commits] rev 25696 - public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources

simon at wyona.com simon at wyona.com
Mon Jul 2 12:53:24 CEST 2007


Author: simon
Date: 2007-07-02 12:53:23 +0200 (Mon, 02 Jul 2007)
New Revision: 25696

Removed:
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/CreateZip.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/InstallInfo.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/TomcatContextHandler.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfo.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfoVersionComparator.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateResource.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/VersionComparator.java
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/WarFetcher.java
Log:
refactored package structure

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/CreateZip.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/CreateZip.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/CreateZip.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,60 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class CreateZip {
-
-    File files[];
-    ZipOutputStream zipOutput;
-
-    public void create(String destFile, File[] files, ArrayList originalPath) {
-        this.files = files;
-        try {
-            zipOutput = new ZipOutputStream(new FileOutputStream(destFile));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        createZip(originalPath);
-        close();
-    }
-    
-    public void createZip(ArrayList originalPath) {
-        try {
-            byte[] buff = new byte[10240];
-            File[] fileList = files;
-
-            for (int i = 0; i < fileList.length; i++) {
-                    FileInputStream fin = new FileInputStream(fileList[i]);
-                    zipOutput.putNextEntry(new ZipEntry(((String) originalPath.get(i))));
-                    int len;
-                    while ((len = fin.read(buff)) > 0) {
-                        zipOutput.write(buff, 0, len);
-                    }
-                    fin.close();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Method used to close the object for ZipOutputStream
-     */
-    public void close() {
-        try {
-            zipOutput.flush();
-            zipOutput.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}
\ No newline at end of file

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/InstallInfo.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/InstallInfo.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/InstallInfo.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,151 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.apache.log4j.Category;
-import java.io.File;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.vocabulary.*;
-import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;
-import javax.servlet.http.HttpServletRequest;
-/**
- * 
- */
-public class InstallInfo {
-    
-    private static Category log = Category.getInstance(InstallInfo.class);
-    private String id;
-    private String version;
-    private String revision;
-    private String installtype;
-    private String contextPrefix;
-    private String updateURL;
-    private String osName; //platform
-    private String javaVersion;
-    private String targetApplicationId;
-    private String targetApplicationVersion;
-    private ArrayList protectedFiles = new ArrayList();
-    
-    private String updateManagerNS = "http://www.wyona.org/update-manager/1.0#"; 
-    
-    public InstallInfo(HttpServletRequest request)  throws java.io.FileNotFoundException{
-        String WEBINFPath = request.getSession().getServletContext().getRealPath("WEB-INF");
-        contextPrefix = request.getSession().getServletContext().getServletContextName();
-        if (contextPrefix.equalsIgnoreCase("ROOT")) {
-            contextPrefix = "ROOT";
-        } else {
-            contextPrefix = contextPrefix.toLowerCase();
-        }
-        InputStream installRdfIn = new FileInputStream(new File(WEBINFPath + File.separator + "classes" + File.separator + "install.rdf"));
-        Model model = ModelFactory.createDefaultModel();
-        //read the RDF/XML file
-        model.read(installRdfIn, "");
-        parseModel(model);
-        
-        setServerInfoDetail(request);
-        
-        osName = System.getProperty("os.name");
-        javaVersion = System.getProperty("java.version");
-    }
-
-    private void parseModel(Model model) {
-        Resource install = model.getResource("urn:wyona:application:install");
-        
-        Property idProperty = new PropertyImpl(updateManagerNS, "id");
-        id = install.getRequiredProperty(idProperty).getString();
-        Property versionProperty = new PropertyImpl(updateManagerNS, "version");
-        version = install.getRequiredProperty(versionProperty).getString();
-        Property revisionProperty = new PropertyImpl(updateManagerNS, "revision");
-        revision = install.getRequiredProperty(revisionProperty).getString();
-        Property installtypeProperty = new PropertyImpl(updateManagerNS, "installtype");
-        installtype = install.getRequiredProperty(installtypeProperty).getString();
-        //Property contextPrefixProperty = new PropertyImpl(updateManagerNS, "contextprefix");
-        //contextPrefix = install.getRequiredProperty(contextPrefixProperty).getString();
-
-        Property updateURLProperty = new PropertyImpl(updateManagerNS, "updateURL");
-        updateURL = install.getRequiredProperty(updateURLProperty).getString();
-
-        Property protectedFilesProperty = new PropertyImpl(updateManagerNS, "protectedFiles");
-        Seq protectedFilesSeq = install.getRequiredProperty(protectedFilesProperty).getSeq();
-        
-        NodeIterator protectedFilesIter = protectedFilesSeq.iterator();
-        while (protectedFilesIter.hasNext()) {
-            protectedFiles.add(protectedFilesIter.next().toString());
-        }
-        
-        /*Property targetApplicationProperty = new PropertyImpl(updateManagerNS, "targetApplication");
-        Resource targetApplication = install.getProperty(targetApplicationProperty).getResource();
-        
-        Property targetApplicationIdProperty = new PropertyImpl(updateManagerNS, "id");
-        targetApplicationId = targetApplication.getRequiredProperty(targetApplicationIdProperty).getString();
-        Property targetApplicationVersionProperty = new PropertyImpl(updateManagerNS, "version");
-        targetApplicationVersion = targetApplication.getRequiredProperty(targetApplicationVersionProperty).getString();*/
-        
-    }
-
-    private void setServerInfoDetail(HttpServletRequest request) {
-        //this needs to be implemented for each servlet container since it doesn't seem the string of getServerInfo() is standardized
-        String serverInfo = request.getSession().getServletContext().getServerInfo();
-        
-        if (serverInfo.startsWith("Apache Tomcat")) {
-            targetApplicationId  = serverInfo.split("/")[0];
-            targetApplicationVersion  = serverInfo.split("/")[1];
-        } else {
-            targetApplicationId  = serverInfo.split("/")[0];
-            targetApplicationVersion  = serverInfo.split("/")[1];
-            log.info("the dedection of the servlet container name and version is just a guess. if there is something wrong please implement your servlets getServerInfo() string. thanks :)");
-        }
-        
-    }
-    
-
-    public String getId() {
-        return id;
-    }
-
-    public String getInstalltype() {
-        return installtype;
-    }
-    public String getContextPrefix() {
-        return contextPrefix;
-    }
-
-    public String getUpdateURL() {
-        return updateURL;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public String getRevision() {
-        return revision;
-    }
-
-    public String getJavaVersion() {
-        return javaVersion;
-    }
-
-    public String getOsName() {
-        return osName;
-    }
-
-    public String getTargetApplicationId() {
-        return targetApplicationId;
-    }
-
-    public String getTargetApplicationVersion() {
-        return targetApplicationVersion;
-    }
-
-    public ArrayList getProtectedFiles() {
-        return protectedFiles;
-    }
-    
-}
\ No newline at end of file

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/TomcatContextHandler.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/TomcatContextHandler.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/TomcatContextHandler.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.apache.log4j.Category;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedWriter;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import javax.servlet.http.HttpServletRequest;
-
-
-
-public class TomcatContextHandler {
-    private static Category log = Category.getInstance(TomcatContextHandler.class);
-    private String webappsDirectoryPath;
-    private File webappsDirectory;
-    private String contextConfPath;
-    private File contextConfDirectory;
-    
-    public TomcatContextHandler(HttpServletRequest request) throws Exception {
-        this.webappsDirectoryPath = request.getSession().getServletContext().getRealPath(".") + File.separator + ".." + File.separator;
-        this.webappsDirectory = new File(webappsDirectoryPath);
-        this.contextConfPath = webappsDirectoryPath  + ".." + File.separator + "conf" + File.separator + "Catalina" + File.separator + "localhost" + File.separator;
-        this.contextConfDirectory = new File(contextConfPath);
-    }
-    
-    public String[] getWebappNames() {
-        String[] webapps = new String[this.webappsDirectory.listFiles().length];
-        for (int i = 0; i < this.webappsDirectory.listFiles().length; i++) {
-            webapps[i] = this.webappsDirectory.listFiles()[i].getName();
-        }
-        return webapps;
-    }
-    
-    public String[] getContextNames() {
-        String[] contexts = new String[this.contextConfDirectory.listFiles().length];
-        for (int i = 0; i < this.contextConfDirectory.listFiles().length; i++) {
-            contexts[i] = this.contextConfDirectory.listFiles()[i].getName().replaceAll(".xml", "");
-            if (contexts[i].equals("ROOT")) {
-                contexts[i] = "/";
-            }
-        }
-        return contexts;
-    }
-    
-    public Map getContextAndWebapp() throws Exception {
-        Map contextAndWebapps = new HashMap();
-        for (int i = 0; i < this.contextConfDirectory.listFiles().length; i++) {
-            String context = this.contextConfDirectory.listFiles()[i].getName().replaceAll(".xml", "");;
-            if (context.equals("ROOT")) {
-                context = "/";
-            }
-            String webapp = getWebappOfContext(context);
-            contextAndWebapps.put(context, webapp);
-        }
-        return contextAndWebapps;
-    }
-    
-    public String getWebappOfContext (String context) throws FileNotFoundException, IOException {
-        File file = new File( contextConfPath +  context);
-        String line = "";
-        String webapp = "";
-
-        FileInputStream fis = new FileInputStream(file);
-        BufferedInputStream  bis = new BufferedInputStream(fis);
-        DataInputStream  dis = new DataInputStream(bis);
-        while (dis.available() != 0) {
-          line = line + dis.readLine();
-        }
-        fis.close();
-        bis.close();
-        dis.close();
-        
-        line = line.replaceAll("[ ]+", " ");
-        line = line.replaceAll("\"/>", "");
-        webapp = line.split(File.separator)[line.split(File.separator).length];
-        
-        return webapp;
-    }
-
-    public void setContext (String context, String webapp) throws Exception, IOException {
-        if (context.equals("/")) {
-            context = "ROOT";
-        }
-        if (!context.equals(webapp) && new  File(contextConfPath + context + ".xml").exists()){
-            log.debug("Its prohibited to modify a context if context name and webapp name are the same.");
-            throw new Exception("Its prohibited to modify a context if context name and webapp name are the same."); 
-        }
-        String contextEntry = "<Context docBase=\"${catalina.home}/yanel-webapps/" + webapp + "\"/>";
-        BufferedWriter out = new BufferedWriter(new FileWriter(contextConfPath + context + ".xml"));
-        out.write(contextEntry);
-        out.close();
-    }
-
-    public void setWebappAsRoot(String webapp) throws Exception {
-        try {
-            setContext ("ROOT", webapp);
-        } catch (Exception e) {
-            log.error("Setting of webapp (" +  webapp + ") as root failed.");
-            throw new Exception("Setting of webapp (" +  webapp + ") as root failed.");
-        }
-    }
-    
-    public void removeWebapp (String webapp, String context) throws Exception {
-        if (context.equals("/") || context.equals("ROOT")) {
-            log.error("Deletion of root context prohibited");
-            throw new Exception("Deletion of root context prohibited. Use setWebappAsRoot(String webapp) instead");
-        }
-        if (!getWebappOfContext(context).equals(webapp)) {
-            log.error("This context (" + context + ") does not point to this webapp (" + webapp + ")");
-            throw new Exception("This context (" + context + ") does not point to this webapp (" + webapp + ")");
-        }
-        boolean success = (new File(contextConfPath + context)).delete();
-        if (!success) {
-            log.error("Deletion of contex file not successful!");
-            throw new Exception("Deletion of contex file (" + contextConfPath + context + ") not successful!");
-        }
-        try {
-            FileUtils.deleteDirectory(new File(webappsDirectoryPath + webapp));
-        } catch (Exception e) {
-            log.error("Deletion of webapp not successful!");
-            throw new Exception("Deletion of webapp (" + webappsDirectoryPath + webapp + ") not successful!" + e);
-        }
-    }
-}
\ No newline at end of file

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfo.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfo.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfo.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,236 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.apache.log4j.Category;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-
-import com.hp.hpl.jena.rdf.model.*;
-import com.hp.hpl.jena.vocabulary.*;
-import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;
-import java.util.HashMap;
-
-/**
- * 
- */
-public class UpdateInfo {
-    
-    private static Category log = Category.getInstance(UpdateInfo.class);
-    private ArrayList updateVersions = new ArrayList();
-    private Model updateRdfModel;
-    private InstallInfo installInfo;
-    
-    private String updateManagerNS = "http://www.wyona.org/update-manager/1.0#"; 
-    
-    public UpdateInfo(InputStream in, InstallInfo installInfo) throws Exception{
-        if (installInfo == null) {
-            throw new Exception("InstallInfo should not be null");
-        }
-        if (in == null) {
-            throw new Exception("InputStream should not be null");
-        }
-        Model model = ModelFactory.createDefaultModel();
-        //read the RDF/XML file
-        model.read(in, "");
-        this.updateRdfModel = model;
-        this.installInfo = installInfo;
-
-        setUpdateVersions();
-    }
-
-    private void setUpdateVersions() {
-        Resource type = updateRdfModel.getResource("urn:wyona:application");
-        Property typeProperty = new PropertyImpl(updateManagerNS, "type");
-        Property typesProperty = new PropertyImpl(updateManagerNS, "types");
-        Property versionsProperty = new PropertyImpl(updateManagerNS, "versions");
-        Seq types = type.getProperty(typesProperty).getSeq();
-        NodeIterator typeIter = types.iterator();
-        
-        while (typeIter.hasNext()) {
-            Resource typeResource = ((Resource) typeIter.next());
-        
-        //Resource update = updateRdfModel.getResource("urn:wyona:application:updates");
-        
-        Property versionProperty = new PropertyImpl(updateManagerNS, "version");
-        Property revisionProperty = new PropertyImpl(updateManagerNS, "revision");
-        //Seq versions = update.getProperty(versionsProperty).getSeq();
-        Seq versionsSeq = typeResource.getProperty(versionsProperty).getSeq();
-        
-        NodeIterator iter2 = versionsSeq.iterator();
-        Property idProperty = new PropertyImpl(updateManagerNS, "id");
-        Property targetApplicationIdProperty = new PropertyImpl(updateManagerNS, "targetApplicationId");
-        Property targetApplicationminVersionProperty = new PropertyImpl(updateManagerNS, "targetApplicationMinVersion");
-        Property targetApplicationmaxVersionProperty = new PropertyImpl(updateManagerNS, "targetApplicationMaxVersion");
-        Property targetApplicationminRevisionProperty = new PropertyImpl(updateManagerNS, "targetApplicationMinRevision");
-        Property targetApplicationmaxRevisionProperty = new PropertyImpl(updateManagerNS, "targetApplicationMaxRevision");
-        Property changeLogProperty = new PropertyImpl(updateManagerNS, "changelog");
-        Property titleProperty = new PropertyImpl(updateManagerNS, "title");
-        Property updateLinkProperty = new PropertyImpl(updateManagerNS, "updateLink");
-        
-        while (iter2.hasNext()) {
-            Resource versionResource = ((Resource) iter2.next());
-            
-            
-            
-            
-            
-            
-            HashMap updateVersionDetail = new HashMap();
-            updateVersionDetail.put("type", typeResource.getProperty(typeProperty).getString());
-            updateVersionDetail.put("title", versionResource.getProperty(titleProperty).getString());
-            updateVersionDetail.put("id", versionResource.getProperty(idProperty).getString());
-            updateVersionDetail.put("version", versionResource.getProperty(versionProperty).getString());
-            updateVersionDetail.put("revision", versionResource.getProperty(revisionProperty).getString());
-            updateVersionDetail.put("changeLog", versionResource.getProperty(changeLogProperty).getString());
-            updateVersionDetail.put("updateLink", versionResource.getProperty(updateLinkProperty).getString());
-            updateVersionDetail.put("targetApllicationId", versionResource.getProperty(idProperty).getString());
-            updateVersionDetail.put("targetApllicationMinVersion", versionResource.getProperty(targetApplicationminVersionProperty).getString());
-            updateVersionDetail.put("targetApllicationMaxVersion", versionResource.getProperty(targetApplicationmaxVersionProperty).getString());
-            updateVersionDetail.put("targetApllicationMinRevision", versionResource.getProperty(targetApplicationminRevisionProperty).getString());
-            updateVersionDetail.put("targetApllicationMaxRevision", versionResource.getProperty(targetApplicationmaxRevisionProperty).getString());
-            this.updateVersions.add(updateVersionDetail);
-            
-            
-            
-            //check id
-            //if (versionResource.getProperty(idProperty).getString().equals(installInfo.getId())) {
-                //check for targetApplicationId
-//                Seq targetApplicationSeq = versionResource.getProperty(targetApplicationProperty).getSeq();
-//                NodeIterator targetApplicationIter = targetApplicationSeq.iterator();
-//                while (targetApplicationIter.hasNext()) {
-//                    Resource targetApplicationResource = ((Resource) targetApplicationIter.next());
-//                    String test1 = targetApplicationResource.getProperty(idProperty).getString();
-//                    String test2 = installInfo.getTargetApplicationId();
-//                    System.out.println("taid: "+test1 +" install: "+ test2);
-//                    
-//                    //if (targetApplicationResource.getProperty(idProperty).getString().equals(installInfo.getTargetApplicationId())) {
-//
-//                        //check for minorVersion
-//                        //String minVersion = targetApplicationResource.getProperty(minVersionProperty).getString();
-//                        //String installVersion = installInfo.getTargetApplicationVersion();
-//                        //VersionComparator versionComparator = new VersionComparator(); 
-//                        //if (versionComparator.compare(installVersion, minVersion) >= 0) {
-//                            //check for maxVersion
-//                            //String maxVersion = targetApplicationResource.getProperty(maxVersionProperty).getString();
-//                            //if (versionComparator.compare(maxVersion, installVersion) >= 0) {
-//                                HashMap updateVersionDetail = new HashMap();
-//                                updateVersionDetail.put("type", typeResource.getProperty(typeProperty).getString());
-//                                updateVersionDetail.put("title", versionResource.getProperty(titleProperty).getString());
-//                                updateVersionDetail.put("id", versionResource.getProperty(idProperty).getString());
-//                                updateVersionDetail.put("version", versionResource.getProperty(versionProperty).getString());
-//                                updateVersionDetail.put("revision", versionResource.getProperty(revisionProperty).getString());
-//                                updateVersionDetail.put("changeLog", versionResource.getProperty(changeLogProperty).getString());
-//                                updateVersionDetail.put("updateLink", targetApplicationResource.getProperty(updateLinkProperty).getString());
-//                                updateVersionDetail.put("targetApllication", targetApplicationResource.getProperty(idProperty).getString());
-//                                updateVersionDetail.put("targetApllicationMinVersion", targetApplicationResource.getProperty(minVersionProperty).getString());
-//                                updateVersionDetail.put("targetApllicationMaxVersion", targetApplicationResource.getProperty(maxVersionProperty).getString());
-//                                this.updateVersions.add(updateVersionDetail);
-//                            //}
-//                        //}
-//                    //}
-//                //}
-//                }
-            }
-        }
-    }
-
-    public ArrayList getUpdateVersions() {
-        return updateVersions;
-    }
-    
-    public HashMap getUpdateVersionDetail(String key, String value) {
-        for (int i = 0; i < updateVersions.size(); i++) {
-            HashMap versionDetail = (HashMap) updateVersions.get(i);
-            if (versionDetail.get(key).equals(value)) {
-                return versionDetail;
-            }
-        }
-        return null;
-    }    
-
-
-    /**
-     * @return ArrayList with version which are matching the value of the key
-     * @param String key
-     * @param String value 
-     */
-    public ArrayList getUpdateVersionsOf(String key, String value) {
-        ArrayList selectedUpdateVersions = updateVersions;
-        for (int i = 0; i < selectedUpdateVersions.size(); i++) {
-            HashMap versionDetail = (HashMap) selectedUpdateVersions.get(i);
-            if (!versionDetail.get(key).equals(value)) {
-                selectedUpdateVersions.remove(i);
-            }
-        }
-        Collections.sort(selectedUpdateVersions, new UpdateInfoVersionComparator());
-        return selectedUpdateVersions;
-    }
-
-    /**
-     * @return ArrayList with version which are matching the value of the key, and fits in the version requirement
-     * @param String key
-     * @param String value 
-     */
-    public ArrayList getUpdateVersionsOf(String key, String value, String installInfoVersion) {
-        ArrayList selectedUpdateVersions = getUpdateVersionsOf(key, value);
-        VersionComparator versionComparator = new VersionComparator();  
-        for (int i = 0; i < selectedUpdateVersions.size(); i++) {
-            HashMap versionDetail = (HashMap) selectedUpdateVersions.get(i);
-            if (versionComparator.compare((String) versionDetail.get("targetApllicationMinVersion"), installInfoVersion) > 0 ) {
-                selectedUpdateVersions.remove(i);
-            }
-            if (versionComparator.compare((String) versionDetail.get("targetApllicationMaxVersion"), installInfoVersion) < 0 ) {
-                selectedUpdateVersions.remove(i);
-            }
-        }
-        Collections.sort(selectedUpdateVersions, new UpdateInfoVersionComparator());
-        return selectedUpdateVersions;
-    }
-    
-    /**
-     * @return HashMap with the newest version which are matching the value of the key
-     * @param String key
-     * @param String value 
-     */
-    public HashMap getNewestUpdateVersionsOf(String key, String value) {
-        ArrayList selectedUpdateVersions = getUpdateVersionsOf(key, value);
-        for (int i = 0; i < selectedUpdateVersions.size(); i++) {
-            HashMap versionDetail = (HashMap) selectedUpdateVersions.get(i);
-            if (!versionDetail.get(key).equals(value)) {
-                selectedUpdateVersions.remove(i);
-            }
-        }
-        Collections.sort(selectedUpdateVersions, new UpdateInfoVersionComparator());
-        return (HashMap) selectedUpdateVersions.get(0);
-    }    
-
-    /**
-     * @return HashMap with the newest version which are matching the value of the key
-     * @param String key
-     * @param String value 
-     */
-    public HashMap getNewestUpdateVersionsOf(String key, String value, String installInfoVersion) {
-        ArrayList selectedUpdateVersions = getUpdateVersionsOf(key, value);
-        VersionComparator versionComparator = new VersionComparator();  
-        for (int i = 0; i < selectedUpdateVersions.size(); i++) {
-            HashMap versionDetail = (HashMap) selectedUpdateVersions.get(i);
-            if (versionComparator.compare((String) versionDetail.get("targetApllicationMinVersion"), installInfoVersion) > 0 ) {
-                selectedUpdateVersions.remove(i);
-            }
-            if (versionComparator.compare((String) versionDetail.get("targetApllicationMaxVersion"), installInfoVersion) < 0 ) {
-                selectedUpdateVersions.remove(i);
-            }
-        }
-        Collections.sort(selectedUpdateVersions, new UpdateInfoVersionComparator());
-        return (HashMap) selectedUpdateVersions.get(0);
-    }    
-    
-    
-}

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfoVersionComparator.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfoVersionComparator.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateInfoVersionComparator.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,18 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import java.util.Comparator;
-import java.util.Map;
-
-public class UpdateInfoVersionComparator implements Comparator {
-    
-    public int compare(Object info, Object anotherInfo) {
-        String version = (String) ((Map) info).get("version");
-        String anotherVersion = (String) ((Map) anotherInfo).get("version");
-        VersionComparator versionComparator = new VersionComparator();
-        return compare(version, anotherVersion);
-    }
-}
\ No newline at end of file

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateResource.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateResource.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/UpdateResource.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,393 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.apache.log4j.Category;
-import org.apache.xml.resolver.tools.CatalogResolver;
-import org.apache.xml.serializer.Serializer;
-import org.wyona.yanel.core.Path;
-import org.wyona.yanel.core.Resource;
-import org.wyona.yanel.core.ResourceConfiguration;
-import org.wyona.yanel.core.api.attributes.ViewableV2;
-import org.wyona.yanel.core.attributes.viewable.View;
-import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
-import javax.servlet.http.HttpServletRequest;
-
-import org.wyona.yanel.core.serialization.SerializerFactory;
-import org.wyona.yanel.core.source.ResourceResolver;
-import org.wyona.yanel.core.transformation.I18nTransformer;
-import org.wyona.yanel.core.transformation.I18nTransformer2;
-import org.wyona.yanel.core.transformation.XIncludeTransformer;
-import org.wyona.yanel.core.util.PathUtil;
-import org.wyona.yanel.impl.resources.UpdateInfo;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import java.io.File;
-
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.net.URL;
-import java.io.InputStream;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-import com.hp.hpl.jena.rdf.model.*;
-
-/**
- * 
- */
-public class UpdateResource extends Resource implements ViewableV2 {
-
-    private static Category log = Category.getInstance(UpdateResource.class);
-    private String defaultLanguage;
-    private String language = null;
-
-    /**
-     * 
-     */
-    public UpdateResource() {
-    }
-
-    /**
-     * 
-     */
-    public boolean exists() {
-        return true;
-    }
-
-    /**
-     * 
-     */
-    public long getSize() {
-        return -1;
-    }
-
-    /**
-     * 
-     */
-    public String getMimeType(String viewId) {
-        if (viewId != null && viewId.equals("source"))
-            return "application/xml";
-        return "application/xhtml+xml";
-    }
-
-    /**
-     * 
-     */
-    public View getView(String viewId) {
-        View view = new View();
-        String mimeType = getMimeType(viewId);
-        view.setMimeType(mimeType);
-
-        try {
-            org.wyona.yarep.core.Repository repo = getRealm().getRepository();
-
-            if (viewId != null && viewId.equals("source")) {
-                view.setInputStream(new java.io.StringBufferInputStream(getScreen()));
-                view.setMimeType("application/xml");
-                return view;
-            }
-
-            String[] xsltPath = getXSLTPath(getPath());
-            if (xsltPath != null) {
-
-                // create reader:
-                XMLReader xmlReader = XMLReaderFactory.createXMLReader();
-                CatalogResolver catalogResolver = new CatalogResolver();
-                xmlReader.setEntityResolver(catalogResolver);
-
-                // create xslt transformer:
-                SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance();
-
-                TransformerHandler[] xsltHandlers = new TransformerHandler[xsltPath.length];
-                for (int i = 0; i < xsltPath.length; i++) {
-                    xsltHandlers[i] = tf.newTransformerHandler(new StreamSource(repo.getNode(xsltPath[i])
-                            .getInputStream()));
-                    xsltHandlers[i].getTransformer().setParameter("yanel.path.name",
-                            PathUtil.getName(getPath()));
-                    xsltHandlers[i].getTransformer().setParameter("yanel.path", getPath());
-                    xsltHandlers[i].getTransformer().setParameter("yanel.back2context",
-                            PathUtil.backToContext(realm, getPath()));
-                    xsltHandlers[i].getTransformer().setParameter("yarep.back2realm",
-                            PathUtil.backToRealm(getPath()));
-
-                    xsltHandlers[i].getTransformer().setParameter("language",
-                            getRequestedLanguage());
-                }
-
-                // create i18n transformer:
-                I18nTransformer2 i18nTransformer = new I18nTransformer2("global",
-                        getRequestedLanguage(),
-                        getRealm().getDefaultLanguage());
-                i18nTransformer.setEntityResolver(catalogResolver);
-
-                // create xinclude transformer:
-                XIncludeTransformer xIncludeTransformer = new XIncludeTransformer();
-                ResourceResolver resolver = new ResourceResolver(this);
-                xIncludeTransformer.setResolver(resolver);
-
-                // create serializer:
-                Serializer serializer = SerializerFactory.getSerializer(SerializerFactory.XHTML_STRICT);
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-                // chain everything together (create a pipeline):
-                xmlReader.setContentHandler(xsltHandlers[0]);
-                for (int i = 0; i < xsltHandlers.length - 1; i++) {
-                    xsltHandlers[i].setResult(new SAXResult(xsltHandlers[i + 1]));
-                }
-                xsltHandlers[xsltHandlers.length - 1].setResult(new SAXResult(xIncludeTransformer));
-                xIncludeTransformer.setResult(new SAXResult(i18nTransformer));
-                i18nTransformer.setResult(new SAXResult(serializer.asContentHandler()));
-                serializer.setOutputStream(baos);
-
-                // execute pipeline:
-                xmlReader.parse(new InputSource(new java.io.StringBufferInputStream(getScreen())));
-
-                // write result into view:
-                view.setInputStream(new ByteArrayInputStream(baos.toByteArray()));
-                return view;
-            } else {
-                log.debug("Mime-Type: " + mimeType);
-                view.setInputStream(new java.io.StringBufferInputStream(getScreen()));
-                return view;
-            }
-        } catch (Exception e) {
-            log.error(e + " (" + getPath() + ", " + getRealm() + ")", e);
-        }
-
-        view.setInputStream(new java.io.StringBufferInputStream(getScreen()));
-        return view;
-    }
-
-    /**
-     * 
-     */
-    public ViewDescriptor[] getViewDescriptors() {
-        ViewDescriptor[] vd = new ViewDescriptor[2];
-        vd[0] = new ViewDescriptor("default");
-        vd[0].setMimeType(getMimeType(null));
-        vd[1] = new ViewDescriptor("source");
-        vd[1].setMimeType(getMimeType("source"));
-        return vd;
-    }
-
-    /**
-     * 
-     */
-    private String getScreen() {
-        StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
-        sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
-        sb.append("<head><title>create resource</title>");
-        sb.append("<link rel=\"stylesheet\" type=\"text/css\" href=\""
-                + PathUtil.getResourcesHtdocsPath(this) + "css/resource-creator.css\"/>");
-        sb.append("<link rel=\"stylesheet\" type=\"text/css\" href=\""
-                + PathUtil.getGlobalHtdocsPath(this) + "yanel-css/progressBar.css\"/>");
-        sb.append("<script src=\"" + PathUtil.getGlobalHtdocsPath(this)
-                + "yanel-js/prototype.js\" type=\"text/javascript\"></script>");
-        sb.append("<script src=\"" + PathUtil.getGlobalHtdocsPath(this)
-                + "yanel-js/progressBar.js\" type=\"text/javascript\"></script>");
-        sb.append("<script src=\"" + PathUtil.getResourcesHtdocsPath(this)
-                + "js/ajaxlookup.js\" type=\"text/javascript\"></script>");
-        sb.append("</head>");
-        sb.append("<body>");
-
-        HttpServletRequest request = getRequest();
-        Enumeration parameters = request.getParameterNames();
-        if (!parameters.hasMoreElements()) {
-            plainRequest(sb);
-        } else {
-            if (request.getParameter("save-as") != null) {
-                plainRequest(sb);
-            } else if (request.getParameter("save") != null) {
-                plainRequest(sb);
-            } else {
-                log.info("Fallback ...");
-                plainRequest(sb);
-            }
-        }
-
-        sb.append("</body>");
-        sb.append("</html>");
-        return sb.toString();
-    }
-
-    private void plainRequest(StringBuffer sb) {
-        
-        UpdateInfo updateInfo = null;
-        InstallInfo installInfo = getInstallInfo(sb);
-        // install.rdf
-//        InstallInfo installInfo = null;
-//        try {
-//            installInfo = new InstallInfo(request);
-//        } catch (Exception e) {
-//            log.error(e.getMessage(), e);
-//            sb.append("<p>Exception: " + e.getMessage() + "</p>");
-//            return;
-//        }
-
-
-        if (!getInstallInfo(sb).getInstalltype().equals("bin-snapshot")) {
-
-            sb.append("<p>");
-            sb.append("This Yanel was not installed from binary. You can only use the updater if you installed yanel from binary. Please use svn up, build.sh");
-            sb.append("</p>");
-
-            // transformer = TransformerFactory.newInstance().newTransformer();
-
-        } else {
-            updateInfo = getUpdateInfo(sb);
-//            try {
-//                URL UpdateRdfUrl = new URL(installInfo.getUpdateURL());
-//                InputStream updateRdfIn = UpdateRdfUrl.openStream();
-//                updateInfo = new UpdateInfo(updateRdfIn, installInfo);
-//            } catch (Exception e) {
-//                log.error(e.getMessage(), e);
-//                sb.append("<p>");
-//                sb.append("Yanel could not get the Update information! " + e);
-//                sb.append("</p>");
-//            }
-        }
-
-        if (updateInfo != null) {
-            
-            if (request.getParameter("update") != null
-                    && request.getParameter("update").equals("update")) {
-                WarFetcher warFetcher = null;
-                try {
-                    String destDir = request.getSession().getServletContext().getRealPath(".") + File.separator + "..";
-                    warFetcher = new WarFetcher(request, request.getParameter("updatelink"), destDir);
-                } catch (Exception e) {
-                    log.error(e.getMessage(), e);
-                    sb.append("<p>Exception: " + e.getMessage() + "</p>");
-                    return;
-                }
-
-                
-                try {
-                    HashMap versionDetails = updateInfo.getUpdateVersionDetail("updateLink", request.getParameter("updatelink"));
-                    String version = (String) versionDetails.get("version");
-                    String revision = (String) versionDetails.get("revision");
-                    String id = (String) versionDetails.get("id");
-                    
-                    warFetcher.fetch();
-                    
-                    TomcatContextHandler tomcatContextHandler = new TomcatContextHandler(request);
-                    tomcatContextHandler.setContext("updater", id + "-v-" + version + "-r-" + revision);
-                    String pathToUpdater = "http://" + request.getServerName() + ":" + request.getServerPort() +"/updater/";
-                    
-                    sb.append("<p>");
-                    sb.append("Update done.");
-                    sb.append("<a href=\"" +pathToUpdater + "\">");
-                    sb.append("go to the Updater!");
-                    sb.append("</a>");
-                    sb.append("</p>");
-                } catch (Exception e) {
-                    log.error(e.getMessage(), e);
-                    sb.append("<p>Update failed. Exception: " + e.getMessage() + "</p>");
-                }
-                
-
-                
-            } else {
-                sb.append("<p>");
-                sb.append("This are the updates which you can get:");
-                sb.append("</p>");
-                sb.append("<ul>");
-                for (int i = 0; i < updateInfo.getUpdateVersions().size(); i++) {
-                    HashMap versionDetails = (HashMap) updateInfo.getUpdateVersions().get(i);
-                    if (versionDetails.get("version") != installInfo.getVersion()) {
-                        sb.append("<li>"
-                                + versionDetails.get("title")
-                                + "<ul>"
-                                + "<li>Version: "
-                                + versionDetails.get("version")
-                                + "</li>"
-                                + "<li>Type: "
-                                + versionDetails.get("type")
-                                + "</li>"
-                                + "<li> ChangeLog: "
-                                + versionDetails.get("changeLog")
-                                + "</li>"
-                                + "<li> <form method=\"post\"><input type=\"submit\" name=\"update\" value=\"update\"></input><input type=\"hidden\" name=\"updatelink\" value=\""
-                                + versionDetails.get("updateLink") + "\"/></form></li>"
-                                + "</ul></li>");
-                    }
-                }
-                sb.append("</ul>");
-            }
-        }
-    }
-
-    private InstallInfo getInstallInfo (StringBuffer sb) {
-        InstallInfo installInfo = null;
-        try {
-            return installInfo = new InstallInfo(request);
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            sb.append("<p>Exception: " + e.getMessage() + "</p>");
-            return null;
-        }
-    }
-    
-    private UpdateInfo getUpdateInfo (StringBuffer sb) {
-        UpdateInfo updateInfo = null;
-        try {
-            URL UpdateRdfUrl = new URL(getInstallInfo(sb).getUpdateURL());
-            InputStream updateRdfIn = UpdateRdfUrl.openStream();
-            return updateInfo = new UpdateInfo(updateRdfIn, getInstallInfo(sb));
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            sb.append("<p>");
-            sb.append("Yanel could not get the Update information! " + e);
-            sb.append("</p>");
-            return null;
-        }
-    }
-    
-//    /**
-//     * Get property value from resource configuration
-//     */
-//    private String getResourceProperty(String name) throws Exception {
-//        ResourceConfiguration rc = getConfiguration();
-//        if (rc != null)
-//            return rc.getProperty(name);
-//        return getRTI().getProperty(name);
-//    }
-
-    /**
-     * Get XSLT path
-     */
-    private String[] getXSLTPath(String path) throws Exception {
-        String[] xsltPath = getResourceConfigProperties("xslt");
-        if (xsltPath != null)
-            return xsltPath;
-        log.info("No XSLT Path within: " + path);
-        return null;
-    }
-}

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/VersionComparator.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/VersionComparator.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/VersionComparator.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,268 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Java XPCOM Bindings.
- *
- * The Initial Developer of the Original Code is
- * IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * IBM Corporation. All Rights Reserved.
- *
- * Contributor(s):
- *   Javier Pedemonte (jhpedemonte at gmail.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-package org.wyona.yanel.impl.resources;
-
-import java.util.Enumeration;
-import java.util.StringTokenizer;
-
-
-
-/**
- * Version strings are dot-separated sequences of version-parts.
- * <p>
- * A version-part consists of up to four parts, all of which are optional:
- * <br><code>
- * &lt;number-a&gt;&lt;string-b&gt;&lt;number-c&gt;
- * &lt;string-d (everything else)&gt;
- * </code> <p>
- * A version-part may also consist of a single asterisk "*" which indicates
- * "infinity".
- * <p>
- * Numbers are base-10, and are zero if left out.
- * Strings are compared bytewise.
- * <p>
- * For additional backwards compatibility, if "string-b" is "+" then
- * "number-a" is incremented by 1 and "string-b" becomes "pre".
- * <p> <pre>
- * 1.0pre1
- * < 1.0pre2  
- *   < 1.0 == 1.0.0 == 1.0.0.0
- *     < 1.1pre == 1.1pre0 == 1.0+
- *       < 1.1pre1a
- *         < 1.1pre1
- *           < 1.1pre10a
- *             < 1.1pre10
- * </pre>
- * Although not required by this interface, it is recommended that
- * numbers remain within the limits of a signed char, i.e. -127 to 128.
- */
-public class VersionComparator {
-
-
-  /**
-   * Compare two version strings
-   * @param A   a version string
-   * @param B   a version string
-   * @return a value less than 0 if A < B; <br>
-   *         the value 0 if A == B; <br>
-   *         or a value greater than 0 if A > B <br>
-   */
-  public int compare(String A, String B) {
-    int result;
-    String a = A, b = B;
-
-    do {
-      VersionPart va = new VersionPart();
-      VersionPart vb = new VersionPart();
-      a = parseVersionPart(a, va);
-      b = parseVersionPart(b, vb);
-
-      result = compareVersionPart(va, vb);
-      if (result != 0) {
-        break;
-      }
-    } while (a != null || b != null);
-
-    return result;
-  }
-
-  private class VersionPart {
-    int     numA = 0;
-    String  strB;
-    int     numC = 0;
-    String  extraD;
-  }
-
-  private static String parseVersionPart(String aVersion, VersionPart result) {
-    if (aVersion == null || aVersion.length() == 0) {
-      return aVersion;
-    }
-
-    StringTokenizer tok = new StringTokenizer(aVersion.trim(), ".");
-    String part = tok.nextToken();
-
-    if (part.equals("*")) {
-      result.numA = Integer.MAX_VALUE;
-      result.strB = "";
-    } else {
-      VersionPartTokenizer vertok = new VersionPartTokenizer(part);
-      try {
-        result.numA = Integer.parseInt(vertok.nextToken());
-      } catch (NumberFormatException e) {
-        // parsing error; default to zero like 'strtol' C function
-        result.numA = 0;
-      }
-
-      if (vertok.hasMoreElements()) {
-        String str = vertok.nextToken();
-
-        // if part is of type "<num>+"
-        if (str.charAt(0) == '+') {
-          result.numA++;
-          result.strB = "pre";
-        } else {
-          // else if part is of type "<num><alpha>..."
-          result.strB = str;
-
-          if (vertok.hasMoreTokens()) {
-            try {
-              result.numC = Integer.parseInt(vertok.nextToken());
-            } catch (NumberFormatException e) {
-              // parsing error; default to zero like 'strtol' C function
-              result.numC = 0;
-            }
-            if (vertok.hasMoreTokens()) {
-              result.extraD = vertok.getRemainder();
-            }
-          }
-        }
-      }
-    }
-
-    if (tok.hasMoreTokens()) {
-      // return everything after "."
-      return aVersion.substring(part.length() + 1);
-    }
-    return null;
-  }
-
-  private int compareVersionPart(VersionPart va, VersionPart vb) {
-    int res = compareInt(va.numA, vb.numA);
-    if (res != 0) {
-      return res;
-    }
-
-    res = compareString(va.strB, vb.strB);
-    if (res != 0) {
-      return res;
-    }
-
-    res = compareInt(va.numC, vb.numC);
-    if (res != 0) {
-      return res;
-    }
-
-    return compareString(va.extraD, vb.extraD);
-  }
-
-  private int compareInt(int n1, int n2) {
-    return n1 - n2;
-  }
-
-  private int compareString(String str1, String str2) {
-    // any string is *before* no string
-    if (str1 == null) {
-      return (str2 != null) ? 1 : 0;
-    }
-
-    if (str2 == null) {
-      return -1;
-    }
-
-    return str1.compareTo(str2);
-  }
-
-}
-
-/**
- * Specialized tokenizer for Mozilla version strings.  A token can
- * consist of one of the four sections of a version string: <code>
- * &lt;number-a&gt;&lt;string-b&gt;&lt;number-c&gt;
- * &lt;string-d (everything else)&gt;</code>.
- */
-class VersionPartTokenizer implements Enumeration {
-
-  String part;
-
-  public VersionPartTokenizer(String aPart) {
-    part = aPart;
-  }
-
-  public boolean hasMoreElements() {
-    return part.length() != 0;
-  }
-
-  public boolean hasMoreTokens() {
-    return part.length() != 0;
-  }
-
-  public Object nextElement() {
-    if (part.matches("[\\+\\-]?[0-9].*")) {
-      // if string starts with a number...
-      int index = 0;
-      if (part.charAt(0) == '+' || part.charAt(0) == '-') {
-        index = 1;
-      }
-
-      while (index < part.length() && Character.isDigit(part.charAt(index))) {
-        index++;
-      }
-
-      String numPart = part.substring(0, index);
-      part = part.substring(index);
-      return numPart;
-    } else {
-      // ... or if this is the non-numeric part of version string
-      int index = 0;
-      while (index < part.length() && !Character.isDigit(part.charAt(index))) {
-        index++;
-      }
-
-      String alphaPart = part.substring(0, index);
-      part = part.substring(index);
-      return alphaPart;
-    }
-  }
-
-  public String nextToken() {
-    return (String) nextElement();
-  }
-
-  /**
-   * Returns what remains of the original string, without tokenization.  This
-   * method is useful for getting the <code>&lt;string-d (everything else)&gt;
-   * </code> section of a version string.
-   * 
-   * @return remaining version string
-   */
-  public String getRemainder() {
-    return part;
-  }
-
-}
-

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/WarFetcher.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/WarFetcher.java	2007-07-02 10:52:40 UTC (rev 25695)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/WarFetcher.java	2007-07-02 10:53:23 UTC (rev 25696)
@@ -1,116 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.apache.log4j.Category;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.io.FileUtils;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.net.JarURLConnection;
-
-
-public class WarFetcher {
-    
-    private static Category log = Category.getInstance(WarFetcher.class);
-    //private String contextDirectoryPath;
-    private String DestinationDirectoryPath;
-    private String updateLink;
-    //private HttpServletRequest request;
-    private InstallInfo installInfo;
-    
-    
-    public WarFetcher(HttpServletRequest request, String updateLink, String destDir) throws Exception {
-        //this.request = request;
-        //this.contextDirectoryPath = request.getSession().getServletContext().getRealPath(".");
-        this.DestinationDirectoryPath = destDir;
-        this.updateLink = updateLink;
-        this.installInfo = new InstallInfo(request);
-    }
-    
-    public void fetch() throws Exception {
-        downloadUpdateWar(updateLink);
-    }
-    
-    //private File getInstalledWar() {
-    //    return new File(contextDirectoryPath + File.separator + ".." + File.separator + installInfo.getContextPrefix() + ".war");
-    //}
-    
-//    private File[] getUpdateProtectedFiles() {
-//        ArrayList FileNames = installInfo.getProtectedFiles();
-//        File[] protectedFiles = new File [FileNames.size()];
-//        for (int i = 0; i < FileNames.size(); i++) {
-//            File protectedFile = new File(contextDirectoryPath + File.separator + ((String) FileNames.get(i)));
-//            protectedFiles[i] = protectedFile; 
-//        }
-//        return protectedFiles;
-//    }
-    
-//    private void backUpProtected() {
-//        CreateZip protectedFile = new CreateZip();
-//        String destFileName = contextDirectoryPath + File.separator + ".." + File.separator + "yanel-conf-" + installInfo.getVersion() + ".zip";
-//        protectedFile.create(destFileName, getUpdateProtectedFiles(), installInfo.getProtectedFiles());
-//    }
-    
-    //private void backUpWar() throws java.io.IOException{
-    //    FileUtils.copyFile(getInstalledWar(), new File(contextDirectoryPath + File.separator + ".." + File.separator + "yanel-" + installInfo.getVersion() + ".jar"));
-    //}
-    
-    private void downloadUpdateWar(String updateLink) throws Exception {
-        URL updateWarUrl = new URL("jar:" + updateLink + "!/");
-        //InputStream updateWarIn = updateWarUrl.openStream();
-
-        JarURLConnection URLcon=(JarURLConnection)(updateWarUrl.openConnection());
-        JarFile jar=URLcon.getJarFile();
-        
-        URL UpdateRdfUrl = new URL(installInfo.getUpdateURL());
-        InputStream updateRdfIn = UpdateRdfUrl.openStream();
-        UpdateInfo updateInfo = new UpdateInfo(updateRdfIn, installInfo);
-        HashMap versionDetails = updateInfo.getUpdateVersionDetail("updateLink", updateLink);
-        String version = (String) versionDetails.get("version");
-        String revision = (String) versionDetails.get("revision");
-        String id = (String) versionDetails.get("id");
-        
-        extractJar(jar, DestinationDirectoryPath + File.separator + id + "-v-" + version + "-r-" + revision);
-//        OutputStream out = new FileOutputStream(contextDirectoryPath + File.separator + ".." + File.separator + id + "-r" + version + ".war");
-//    
-//        byte[] buf = new byte[1024];
-//        int len;
-//        while ((len = updateWarIn.read(buf)) > 0) {
-//            out.write(buf, 0, len);
-//        }
-//        updateWarIn.close();
-//        out.close();
-    }
-    
-    private void extractJar(JarFile jar, String destDir) throws Exception {
-        new File(destDir).mkdir();
-        java.util.Enumeration entries = jar.entries();
-            while (entries.hasMoreElements()) {
-                java.util.jar.JarEntry file = (java.util.jar.JarEntry) entries.nextElement();
-                java.io.File f = new java.io.File(destDir + java.io.File.separator + file.getName());
-                if (file.isDirectory()) { // if its a directory, create it
-                    f.mkdir();
-                    continue;
-                }
-                java.io.InputStream is = jar.getInputStream(file); // get the input stream
-                java.io.FileOutputStream fos = new java.io.FileOutputStream(f);
-                while (is.available() > 0) { // write contents of 'is' to 'fos'
-                    fos.write(is.read());
-                }
-                fos.close();
-                is.close();
-            }
-    }
-}
\ No newline at end of file




More information about the Yanel-commits mailing list