    public static String gerarDigest(String mensagem) {
        String mensagemCriptografada = null;
        try {
            MessageDigest md = MessageDigest.getInstance("SHA");
            System.out.println("Mensagem original: " + mensagem);
            md.update(mensagem.getBytes());
            byte[] digest = md.digest();
            mensagemCriptografada = converterBytesEmHexa(digest);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mensagemCriptografada;
    }


        private String readCreditsHtml(IApplication app) {
            final URL url = app.getResources().getCreditsURL();
            StringBuffer buf = new StringBuffer(2048);
            if (url != null) {
                try {
                    BufferedReader rdr = new BufferedReader(new InputStreamReader(url.openStream()));
                    try {
                        String line = null;
                        while ((line = rdr.readLine()) != null) {
                            String internationalizedLine = Utilities.replaceI18NSpanLine(line, s_stringMgr);
                            buf.append(internationalizedLine);
                        }
                    } finally {
                        rdr.close();
                    }
                } catch (IOException ex) {
                    String errorMsg = s_stringMgr.getString("AboutBoxDialog.error.creditsfile");
                    s_log.error(errorMsg, ex);
                    buf.append(errorMsg + ": " + ex.toString());
                }
            } else {
                String errorMsg = s_stringMgr.getString("AboutBoxDialog.error.creditsfileurl");
                s_log.error(errorMsg);
                buf.append(errorMsg);
            }
            return buf.toString();
        }


    public void load(String filename) throws VisbardException {
        String defaultFilename = VisbardMain.getSettingsDir() + File.separator + DEFAULT_SETTINGS_FILE;
        File defaultFile = new File(defaultFilename);
        InputStream settingsInStreamFromFile = null;
        try {
            sLogger.info("Loading settings from : " + defaultFilename);
            settingsInStreamFromFile = new FileInputStream(defaultFile);
        } catch (FileNotFoundException fnf) {
            sLogger.info("Unable to load custom settings from user's settings directory (" + fnf.getMessage() + "); reverting to default settings");
            try {
                InputStream settingsInStreamFromJar = VisbardMain.class.getClassLoader().getResourceAsStream(filename);
                FileOutputStream settingsOutStream = new FileOutputStream(defaultFile);
                int c;
                while ((c = settingsInStreamFromJar.read()) != -1) settingsOutStream.write(c);
                settingsInStreamFromJar.close();
                settingsOutStream.close();
                settingsInStreamFromFile = new FileInputStream(defaultFile);
            } catch (IOException ioe) {
                sLogger.warn("Unable to copy default settings to user's settings directory (" + ioe.getMessage() + "); using default settings from ViSBARD distribution package");
                settingsInStreamFromFile = VisbardMain.class.getClassLoader().getResourceAsStream(filename);
            }
        }
        this.processSettingsFile(settingsInStreamFromFile, filename);
    }


    void run(PseudolocalizerArguments arguments) throws IOException {
        List<String> fileNames = arguments.getFileNames();
        PseudolocalizationPipeline pipeline = arguments.getPipeline();
        if (arguments.isInteractive()) {
            runStdin(pipeline);
            return;
        }
        if (fileNames.size() == 0) {
            MessageCatalog msgCat = FormatRegistry.getMessageCatalog(arguments.getType());
            writeMessages(msgCat, readAndProcessMessages(pipeline, msgCat, System.in), System.out);
            return;
        }
        String suffix = arguments.getVariant();
        if (suffix == null) {
            suffix = "_pseudo";
        } else {
            suffix = "_" + suffix;
        }
        for (String fileName : fileNames) {
            File file = new File(fileName);
            if (!file.exists()) {
                System.err.println("File " + fileName + " not found");
                continue;
            }
            int lastDot = fileName.lastIndexOf('.');
            String extension;
            String outFileName;
            if (lastDot >= 0) {
                extension = fileName.substring(lastDot + 1);
                outFileName = fileName.substring(0, lastDot) + suffix + "." + extension;
            } else {
                extension = "";
                outFileName = fileName + suffix;
            }
            System.out.println("Processing " + fileName + " into " + outFileName);
            String fileType = arguments.getType();
            if (fileType == null) {
                fileType = extension;
            }
            MessageCatalog msgCat = FormatRegistry.getMessageCatalog(fileType);
            InputStream inputStream = new FileInputStream(file);
            List<Message> processedMessages = readAndProcessMessages(pipeline, msgCat, inputStream);
            OutputStream outputStream = new FileOutputStream(new File(outFileName));
            writeMessages(msgCat, processedMessages, outputStream);
        }
    }


    public JspBaseTestCase(String name) {
        super(name);
        String propertyFile = "bugbase.properties";
        Properties properties = new Properties();
        setProperties(properties);
        try {
            URL url = this.getClass().getResource("/" + propertyFile);
            if (url != null) {
                InputStream is = url.openStream();
                properties.load(is);
                is.close();
                getLog().debug("Cactus LogService successfully instantiated.");
                getLog().debug("Log4J successfully instantiated.");
            }
        } catch (IOException e) {
            System.err.println("ERROR: cannot load " + propertyFile + "!");
        }
        setDefault("openfuture.bugbase.test.host", "localhost:8080");
        setDefault("openfuture.bugbase.test.context", "bugbase");
        setDefault("openfuture.bugbase.test.userid", "admin");
        setDefault("openfuture.bugbase.test.password", "bugbase");
        setDefault("openfuture.bugbase.test.project", "BugBase Test");
    }


    public static void copyFile(final String inFile, final String outFile) {
        FileChannel in = null;
        FileChannel out = null;
        try {
            in = new FileInputStream(inFile).getChannel();
            out = new FileOutputStream(outFile).getChannel();
            in.transferTo(0, in.size(), out);
        } catch (final Exception e) {
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (final Exception e) {
                }
            }
            if (out != null) {
                try {
                    out.close();
                } catch (final Exception e) {
                }
            }
        }
    }


private void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");
        ServletContext ctx = getServletContext();
        RequestDispatcher rd = ctx.getRequestDispatcher(SETUP_JSP);
        HttpSession session = request.getSession(false);
        if (session == null) {
            session = request.getSession(true);
            session.setAttribute(ERROR_TAG, "You need to have run the Sniffer before running " + "the Grinder. Go to the start page " + " to run the Sniffer.");
            rd = ctx.getRequestDispatcher(ERROR_JSP);
        } else {
            session.setMaxInactiveInterval(-1);
            String pValue = request.getParameter(ACTION_TAG);
            if (pValue != null && pValue.equals(START_TAG)) {
                rd = ctx.getRequestDispatcher(WAIT_JSP);
                int p = 1;
                int t = 1;
                int c = 1;
                try {
                    p = Integer.parseInt(request.getParameter("procs"));
                    p = p > MAX_PROCS ? MAX_PROCS : p;
                } catch (NumberFormatException e) {
                }
                try {
                    t = Integer.parseInt(request.getParameter("threads"));
                    t = t > MAX_THREADS ? MAX_THREADS : t;
                } catch (NumberFormatException e) {
                }
                try {
                    c = Integer.parseInt(request.getParameter("cycles"));
                    c = c > MAX_CYCLES ? MAX_CYCLES : c;
                } catch (NumberFormatException e) {
                }
                try {
                    String dirname = (String) session.getAttribute(OUTPUT_TAG);
                    File workdir = new File(dirname);
                    (new File(dirname + File.separator + LOG_DIR)).mkdir();
                    FileInputStream gpin = new FileInputStream(GPROPS);
                    FileOutputStream gpout = new FileOutputStream(dirname + File.separator + GPROPS);
                    copyBytes(gpin, gpout);
                    gpin.close();
                    InitialContext ictx = new InitialContext();
                    Boolean isSecure = (Boolean) session.getAttribute(SECURE_TAG);
                    if (isSecure.booleanValue()) {
                        gpout.write(("grinder.plugin=" + "net.grinder.plugin.http.HttpsPlugin" + "\n").getBytes());
                        String certificate = (String) ictx.lookup(CERTIFICATE);
                        String password = (String) ictx.lookup(PASSWORD);
                        gpout.write(("grinder.plugin.parameter.clientCert=" + certificate + "\n").getBytes());
                        gpout.write(("grinder.plugin.parameter.clientCertPassword=" + password + "\n").getBytes());
                    } else {
                        gpout.write(("grinder.plugin=" + "net.grinder.plugin.http.HttpPlugin\n").getBytes());
                    }
                    gpout.write(("grinder.processes=" + p + "\n").getBytes());
                    gpout.write(("grinder.threads=" + t + "\n").getBytes());
                    gpout.write(("grinder.cycles=" + c + "\n").getBytes());
                    gpin = new FileInputStream(dirname + File.separator + SNIFFOUT);
                    copyBytes(gpin, gpout);
                    gpin.close();
                    gpout.close();
                    String classpath = (String) ictx.lookup(CLASSPATH);
                    String cmd[] = new String[JAVA_PROCESS.length + 1 + GRINDER_PROCESS.length];
                    int i = 0;
                    int n = JAVA_PROCESS.length;
                    System.arraycopy(JAVA_PROCESS, 0, cmd, i, n);
                    cmd[n] = classpath;
                    i = n + 1;
                    n = GRINDER_PROCESS.length;
                    System.arraycopy(GRINDER_PROCESS, 0, cmd, i, n);
                    for (int j = 0; j < cmd.length; ++j) {
                        System.out.print(cmd[j] + " ");
                    }
                    Process proc = Runtime.getRuntime().exec(cmd, null, workdir);
                    session.setAttribute(PROCESS_TAG, proc);
                } catch (NamingException e) {
                    e.printStackTrace();
                    session.setAttribute(ERROR_MSG_TAG, e.toString());
                    session.setMaxInactiveInterval(TIMEOUT);
                    rd = ctx.getRequestDispatcher(ERROR_JSP);
                } catch (Throwable e) {
                    e.printStackTrace(response.getWriter());
                    throw new IOException(e.getMessage());
                }
            } else if (pValue != null && pValue.equals(CHECK_TAG)) {
                boolean finished = true;
                try {
                    Process p = (Process) session.getAttribute(PROCESS_TAG);
                    int result = p.exitValue();
                } catch (IllegalThreadStateException e) {
                    finished = false;
                }
                if (finished) {
                    session.setMaxInactiveInterval(TIMEOUT);
                    rd = ctx.getRequestDispatcher(RESULTS_JSP);
                } else {
                    rd = ctx.getRequestDispatcher(WAIT_JSP);
                }
            }
            try {
                rd.forward(request, response);
            } catch (ServletException e) {
                e.printStackTrace(response.getWriter());
                throw new IOException(e.getMessage());
            }
        }
    }


    private Component createLicensePane(String propertyKey) {
        if (licesePane == null) {
            String licenseText = "";
            BufferedReader in = null;
            try {
                String filename = "conf/LICENSE.txt";
                java.net.URL url = FileUtil.toURL(filename);
                in = new BufferedReader(new InputStreamReader(url.openStream()));
                String line = null;
                while (true) {
                    line = in.readLine();
                    if (line == null) break;
                    licenseText += line;
                }
            } catch (Exception e) {
                log.error(e);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (Exception e) {
                    }
                }
            }
            licenseText = StringUtils.replace(licenseText, "<br>", "\n");
            licenseText = StringUtils.replace(licenseText, "<p>", "\n\n");
            StyleContext context = new StyleContext();
            StyledDocument document = new DefaultStyledDocument(context);
            Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
            StyleConstants.setAlignment(style, StyleConstants.ALIGN_CENTER);
            StyleConstants.setSpaceAbove(style, 4);
            StyleConstants.setSpaceBelow(style, 4);
            StyleConstants.setFontSize(style, 14);
            try {
                document.insertString(document.getLength(), licenseText, style);
            } catch (BadLocationException e) {
                log.error(e);
            }
            JTextPane textPane = new JTextPane(document);
            textPane.setEditable(false);
            licesePane = new JScrollPane(textPane);
        }
        return licesePane;
    }


    private static String processRequest(String request, HttpMethod method) {
        SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
        URI uri = null;
        try {
            uri = new URI(request);
            ClientHttpRequest clientHttpRequest = simpleClientHttpRequestFactory.createRequest(uri, method);
            ClientHttpResponse response = clientHttpRequest.execute();
            InputStream bodyInputStream = response.getBody();
            String body = org.apache.commons.io.IOUtils.toString(bodyInputStream);
            return body;
        } catch (URISyntaxException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }


    public String[] getFile() {
        List<String> records = new ArrayList<String>();
        FTPClient ftp = new FTPClient();
        try {
            int reply;
            FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
            ftp.configure(conf);
            ftp.connect(host, port);
            System.out.println("Connected to " + host + ".");
            System.out.print(ftp.getReplyString());
            reply = ftp.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftp.disconnect();
                System.err.println("FTP server refused connection.");
            }
            ftp.login(user, password);
            reply = ftp.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftp.disconnect();
                System.err.println("FTP server refused login.");
            }
            InputStream is = ftp.retrieveFileStream(remotedir + "/" + remotefile);
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            while ((line = br.readLine()) != null) {
                if (!line.equals("")) {
                    records.add(line);
                }
            }
            br.close();
            isr.close();
            is.close();
            ftp.logout();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (ftp.isConnected()) {
                try {
                    ftp.disconnect();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
        }
        return records.toArray(new String[0]);
    }


    public JythonWrapperAction(AActionBO.ActionDTO dto, URL url) throws IOException {
        super(dto);
        InputStream in = url.openStream();
        InputStreamReader rin = new InputStreamReader(in);
        BufferedReader reader = new BufferedReader(rin);
        StringBuffer s = new StringBuffer();
        String str;
        while ((str = reader.readLine()) != null) {
            s.append(str);
            s.append("\n");
        }
        in.close();
        script = s.toString();
    }


    private String protectMarkup(String content, String markupRegex, String replaceSource, String replaceTarget) {
        Matcher matcher = Pattern.compile(markupRegex, Pattern.MULTILINE | Pattern.DOTALL).matcher(content);
        StringBuffer result = new StringBuffer();
        while (matcher.find()) {
            String protectedMarkup = matcher.group();
            protectedMarkup = protectedMarkup.replaceAll(replaceSource, replaceTarget);
            try {
                MessageDigest digest = MessageDigest.getInstance("MD5");
                digest.reset();
                digest.update(protectedMarkup.getBytes("UTF-8"));
                String hash = bytesToHash(digest.digest());
                matcher.appendReplacement(result, hash);
                c_protectionMap.put(hash, protectedMarkup);
                m_hashList.add(hash);
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        matcher.appendTail(result);
        return result.toString();
    }


	public static void decompress(File apps,File f) throws IOException{
		String filename=f.getName();
		filename=filename.substring(0,filename.length()-PACK_FILE_SUFFIX.length());
		File dir=new File(apps,filename);
		if(!dir.exists()){
			dir.mkdirs();
		}
		if(dir.isDirectory()){
			JarFile jar=new JarFile(f);
			Enumeration<JarEntry> files=jar.entries();
			while(files.hasMoreElements()){
				JarEntry je=files.nextElement();
				if(je.isDirectory()){
					File item=new File(dir,je.getName());
					item.mkdirs();
				}else{
					File item=new File(dir,je.getName());
					item.getParentFile().mkdirs();
					InputStream input=jar.getInputStream(je);
					FileOutputStream out=new FileOutputStream(item);
					IOUtils.copy(input, out);
					input.close();
					out.close();
				}
				//System.out.println(je.isDirectory() + je.getName());
			}
		}
	}


    private static InputSource getInputSourceFromURI(String uri, String username, String password) throws IOException, ProtocolException, UnsupportedEncodingException {
        URL wsdlurl = null;
        try {
            wsdlurl = new URL(uri);
        } catch (MalformedURLException e) {
            return new InputSource(uri);
        }
        if (username == null && wsdlurl.getUserInfo() == null) {
            return new InputSource(uri);
        }
        if (!wsdlurl.getProtocol().startsWith("http")) {
            return new InputSource(uri);
        }
        URLConnection connection = wsdlurl.openConnection();
        if (!(connection instanceof HttpURLConnection)) {
            return new InputSource(uri);
        }
        HttpURLConnection uconn = (HttpURLConnection) connection;
        String userinfo = wsdlurl.getUserInfo();
        uconn.setRequestMethod("GET");
        uconn.setAllowUserInteraction(false);
        uconn.setDefaultUseCaches(false);
        uconn.setDoInput(true);
        uconn.setDoOutput(false);
        uconn.setInstanceFollowRedirects(true);
        uconn.setUseCaches(false);
        String auth = null;
        if (userinfo != null) {
            auth = userinfo;
        } else if (username != null) {
            auth = (password == null) ? username : username + ":" + password;
        }
        if (auth != null) {
            uconn.setRequestProperty("Authorization", "Basic " + base64encode(auth.getBytes(httpAuthCharEncoding)));
        }
        uconn.connect();
        return new InputSource(uconn.getInputStream());
    }


    private String digestMd5(final String password) {
        String base64;
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(password.getBytes());
            base64 = fr.cnes.sitools.util.Base64.encodeBytes(digest.digest());
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        return "{MD5}" + base64;
    }


    private FTPClient getClient() throws SocketException, IOException {
        FTPClient ftp = new FTPClient();
        ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
        ftp.setDefaultPort(getPort());
        ftp.connect(getIp());
        int reply = ftp.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply)) {
            log.warn("FTP server refused connection: {}", getIp());
            ftp.disconnect();
            return null;
        }
        if (!ftp.login(getUsername(), getPassword())) {
            log.warn("FTP server refused login: {}, user: {}", getIp(), getUsername());
            ftp.logout();
            ftp.disconnect();
            return null;
        }
        ftp.setControlEncoding(getEncoding());
        ftp.setFileType(FTP.BINARY_FILE_TYPE);
        ftp.enterLocalPassiveMode();
        return ftp;
    }


    public static PortalConfig install(File xml, File dir) throws IOException, ConfigurationException {
        if (!dir.exists()) {
            log.info("Creating directory {}", dir);
            dir.mkdirs();
        }
        if (!xml.exists()) {
            log.info("Installing default configuration to {}", xml);
            OutputStream output = new FileOutputStream(xml);
            try {
                InputStream input = ResourceLoader.open("res://" + PORTAL_CONFIG_XML);
                try {
                    IOUtils.copy(input, output);
                } finally {
                    input.close();
                }
            } finally {
                output.close();
            }
        }
        return create(xml, dir);
    }


    public static InputStream getResourceAsStream(String resName, Class<?> clazz) {
        URL url = getResource(resName, clazz);
        try {
            return (url != null) ? url.openStream() : null;
        } catch (IOException e) {
            return null;
        }
    }


    @Test
    public void test00_reinitData() throws Exception {
        Logs.logMethodName();
        init();
        Db db = DbConnection.defaultCieDbRW();
        try {
            db.begin();
            PreparedStatement pst = db.prepareStatement("TRUNCATE e_module;");
            pst.executeUpdate();
            pst = db.prepareStatement("TRUNCATE e_application_version;");
            pst.executeUpdate();
            ModuleHelper.synchronizeDbWithModuleList(db);
            ModuleHelper.declareNewVersion(db);
            ModuleHelper.updateModuleVersions(db);
            esisId = com.entelience.directory.PeopleFactory.lookupUserName(db, "esis");
            assertNotNull(esisId);
            guestId = com.entelience.directory.PeopleFactory.lookupUserName(db, "guest");
            assertNotNull(guestId);
            extenId = com.entelience.directory.PeopleFactory.lookupUserName(db, "exten");
            assertNotNull(extenId);
            db.commit();
        } catch (Exception e) {
            db.rollback();
            throw e;
        }
    }


    public boolean testConnection(FTPSite site) throws IOException {
        FTPClient testclient = new FTPClient();
        testclient.connect(site.getHost(), site.getPort());
        boolean check = testclient.login(site.getUser(), site.getPassword());
        testclient.disconnect();
        return check;
    }


    public static String[] getHints(String query) {
        try {
            URL url = new URL("http://www.ebi.ac.uk/integr8/OrganismSearch.do?action=orgNames&orgName=" + query);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String inputLine;
            String dest = new String();
            while ((inputLine = in.readLine()) != null) dest = dest.concat(inputLine);
            in.close();
            Matcher m = taxonPattern.matcher(dest);
            ArrayList<String> strings = new ArrayList<String>();
            while (m.find()) {
                strings.add(m.group(1));
            }
            return strings.toArray(new String[] {});
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new String[0];
    }


    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String selectedPage = request.getParameter("SelectedPage");
        Page page = null;
        PortalRequest portalRequest = PortalRequest.getCurrentRequest();
        if (selectedPage == null) {
            try {
                Property pageProp = Property.getProperty("HomePage");
                selectedPage = pageProp.getValue();
            } catch (PersistentModelException e) {
                myLogger.info("Page could not be found due to an exception");
                response.sendError(response.SC_NOT_FOUND);
                return;
            }
        }
        myLogger.info("Handling Page Request for Page " + selectedPage);
        try {
            if (page == null) {
                try {
                    page = Page.getPage(Long.parseLong(selectedPage));
                } catch (NumberFormatException e) {
                    List<Page> possiblePage = Page.findByName(selectedPage);
                    if (possiblePage.size() > 0) {
                        page = possiblePage.get(0);
                    } else {
                        response.sendError(response.SC_NOT_FOUND);
                        return;
                    }
                }
            }
            if (!page.isVisibleTo(portalRequest.getCurrentUser())) {
                Property pageProp = Property.getProperty("HomePage");
                selectedPage = pageProp.getValue();
                page = Page.getPage(Long.parseLong(selectedPage));
            }
            try {
                Property property = Property.getProperty("LogPageRequests");
                if (property.getValue().toLowerCase().equals("true")) {
                    String referer = request.getHeader("Referer");
                    if (referer == null || referer.indexOf(portalRequest.getRequest().getServerName()) > 0) {
                        referer = " ";
                    } else {
                        if (referer.length() >= 200) {
                            referer = referer.substring(0, 198);
                        }
                    }
                    PageRequest.createRequest(portalRequest.getCurrentHREF(), page, portalRequest.getCurrentUser(), portalRequest.getRequest().getRemoteAddr(), referer);
                }
            } catch (PersistentModelException e) {
                myLogger.log(Level.WARNING, "Log Page Requests property was not found.", e);
            }
            if (page.isVisibleTo(portalRequest.getCurrentUser())) {
                HttpSession session = request.getSession();
                if (session != null) {
                    RecentlyViewedManager rvm = (RecentlyViewedManager) session.getAttribute("ipoint.RecentlyViewedManager");
                    if (rvm == null) {
                        rvm = new RecentlyViewedManager();
                    }
                    rvm.add(page);
                    session.setAttribute("ipoint.RecentlyViewedManager", rvm);
                }
                PageCacheEntry entry = null;
                if (!portalRequest.isPost() && !page.isEditableBy(portalRequest.getCurrentUser())) {
                    try {
                        int pageCacheTime = 60000;
                        try {
                            Property pageCacheTimeProperty = Property.getProperty("PageCacheTime");
                            pageCacheTime = Integer.parseInt(pageCacheTimeProperty.getValue());
                            pageCacheTime *= 1000;
                        } catch (PersistentModelException pme) {
                            myLogger.warning("Ignoring Exception when retrieving PageCacheTime property");
                        } catch (NumberFormatException nfe) {
                        }
                        entry = PageCacheEntry.find(portalRequest.getCurrentHREF(), page, portalRequest.getCurrentUser(), pageCacheTime);
                    } catch (PersistentModelException e) {
                        myLogger.log(Level.WARNING, "An error occurred finding a page cache entry", e);
                    }
                }
                response.setContentType("text/html");
                response.setHeader("Cache-Control", "no-cache");
                boolean processed = false;
                if (entry != null) {
                    String tempFile = entry.getTempFile();
                    File file = new File(tempFile);
                    if (file.exists() && file.isFile() && file.canRead()) {
                        FileReader reader = new FileReader(file);
                        BufferedReader br = new BufferedReader(reader);
                        PrintWriter out = response.getWriter();
                        out.write("<!-- Starting to output cached page in " + portalRequest.elapsedTime() + " ms -->\n");
                        while (br.ready()) {
                            out.write(br.readLine() + "\n");
                        }
                        out.write("<!-- Cached output produced in " + portalRequest.elapsedTime() + " ms -->\n");
                        reader.close();
                        processed = true;
                        portalRequest.getMBeans().incrementStatistics(ManagementMBeans.StatisticsType.PageTotal, page.getName() + "-" + page.getID(), portalRequest.elapsedTime(), true);
                    } else {
                        entry.delete();
                    }
                }
                if (!processed) {
                    PrintWriter out = response.getWriter();
                    out.write("<!-- Output produced by iPoint Portal -->\n");
                    PageRenderer renderer = new PageRenderer(page);
                    long startTime = System.currentTimeMillis();
                    request.setAttribute(ELConstants.IPOINT_USER, portalRequest.getCurrentUser());
                    request.setAttribute(ELConstants.IPOINT_PAGE, page);
                    request.setAttribute(ELConstants.IPOINT_TEMPLATE, page.getTemplate());
                    request.setAttribute(ELConstants.IPOINT_PORTAL_PROPERTIES, Property.getPropertiesMap());
                    request.setAttribute(ELConstants.IPOINT_USER_PROPERTIES, portalRequest.getCurrentUser().getProperties());
                    renderer.preProcess();
                    portalRequest.getMBeans().incrementStatistics(ManagementMBeans.StatisticsType.PagePreProcess, page.getName() + "-" + page.getID(), System.currentTimeMillis() - startTime, false);
                    long renderStart = System.currentTimeMillis();
                    renderer.render();
                    portalRequest.getMBeans().incrementStatistics(ManagementMBeans.StatisticsType.PageRender, page.getName() + "-" + page.getID(), System.currentTimeMillis() - renderStart, false);
                    portalRequest.getMBeans().incrementStatistics(ManagementMBeans.StatisticsType.PageTotal, page.getName() + "-" + page.getID(), System.currentTimeMillis() - startTime, false);
                    out.write("<!-- output produced in " + PortalRequest.getCurrentRequest().elapsedTime() + " ms -->\n");
                    if (!page.isEditableBy(portalRequest.getCurrentUser())) {
                        if (response instanceof CachingResponseWrapper) {
                            CachingResponseWrapper crw = (CachingResponseWrapper) response;
                            crw.flushBuffer();
                            Property tempProperty = Property.getProperty("UploadLocation");
                            File tempDirectory = new File(tempProperty.getValue());
                            if (tempDirectory.exists() && tempDirectory.canWrite()) {
                                File file = File.createTempFile("iPointPage", ".html", tempDirectory);
                                try {
                                    FileWriter fw = new FileWriter(file);
                                    fw.write(crw.getOutput());
                                    fw.flush();
                                    fw.close();
                                    PageCacheEntry.create(portalRequest.getCurrentHREF(), page, portalRequest.getCurrentUser(), file.getAbsolutePath());
                                } catch (IOException e) {
                                }
                            } else {
                                myLogger.warning("Can not write to directory " + tempProperty.getValue());
                            }
                        }
                    }
                }
            } else {
                myLogger.info("Current User is Forbidden from seeing this Page");
                response.sendError(response.SC_FORBIDDEN);
            }
        } catch (PersistentModelException e) {
            myLogger.log(Level.INFO, "Unable to find page " + selectedPage, e);
            response.sendError(response.SC_NOT_FOUND);
        } catch (PresentationException pe) {
            pe.printStackTrace();
            throw new ServletException("Error processing the page", pe);
        }
    }


    public static String encryptPassword(String plainPassword) {
        StringBuffer sb = new StringBuffer();
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(plainPassword.getBytes());
            byte[] digestBytes = messageDigest.digest();
            String hex = null;
            for (int i = 0; i < digestBytes.length; i++) {
                hex = Integer.toHexString(0xFF & digestBytes[i]);
                if (hex.length() < 2) sb.append("0");
                sb.append(hex);
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return new String(sb);
    }


    public static String getMD5HashFromString(String message) {
        String hashword = null;
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(message.getBytes());
            BigInteger hash = new BigInteger(1, md5.digest());
            hashword = hash.toString(16);
        } catch (NoSuchAlgorithmException nsae) {
        }
        return hashword;
    }


    private static String readURL(URL url) throws IOException {
        BufferedReader in = null;
        StringBuffer s = new StringBuffer();
        try {
            in = new BufferedReader(new InputStreamReader(url.openStream()));
            String str;
            while ((str = in.readLine()) != null) {
                s.append(str);
            }
        } finally {
            if (in != null) in.close();
        }
        return s.toString();
    }


        public void actionPerformed(ActionEvent e) {
            if (saveForWebChooser == null) {
                ExtensionFileFilter fileFilter = new ExtensionFileFilter("HTML files");
                fileFilter.addExtension("html");
                saveForWebChooser = new JFileChooser();
                saveForWebChooser.setFileFilter(fileFilter);
                saveForWebChooser.setDialogTitle("Save for Web...");
                saveForWebChooser.setCurrentDirectory(new File(Config.getRecentDirectory("recentSaveForWebDirectory")));
            }
            if (saveForWebChooser.showSaveDialog(Main.this) == JFileChooser.APPROVE_OPTION) {
                Config.setRecentDirectory("recentSaveForWebDirectory", saveForWebChooser.getCurrentDirectory().getAbsolutePath());
                File pathFile = saveForWebChooser.getSelectedFile().getParentFile();
                String name = saveForWebChooser.getSelectedFile().getName();
                if (!name.toLowerCase().endsWith(".html") && name.indexOf('.') == -1) {
                    name = name + ".html";
                }
                String resource = MIDletClassLoader.getClassResourceName(this.getClass().getName());
                URL url = this.getClass().getClassLoader().getResource(resource);
                String path = url.getPath();
                int prefix = path.indexOf(':');
                String mainJarFileName = path.substring(prefix + 1, path.length() - resource.length());
                File appletJarDir = new File(new File(mainJarFileName).getParent(), "lib");
                File appletJarFile = new File(appletJarDir, "microemu-javase-applet.jar");
                if (!appletJarFile.exists()) {
                    appletJarFile = null;
                }
                if (appletJarFile == null) {
                }
                if (appletJarFile == null) {
                    ExtensionFileFilter fileFilter = new ExtensionFileFilter("JAR packages");
                    fileFilter.addExtension("jar");
                    JFileChooser appletChooser = new JFileChooser();
                    appletChooser.setFileFilter(fileFilter);
                    appletChooser.setDialogTitle("Select MicroEmulator applet jar package...");
                    appletChooser.setCurrentDirectory(new File(Config.getRecentDirectory("recentAppletJarDirectory")));
                    if (appletChooser.showOpenDialog(Main.this) == JFileChooser.APPROVE_OPTION) {
                        Config.setRecentDirectory("recentAppletJarDirectory", appletChooser.getCurrentDirectory().getAbsolutePath());
                        appletJarFile = appletChooser.getSelectedFile();
                    } else {
                        return;
                    }
                }
                JadMidletEntry jadMidletEntry;
                Iterator it = common.jad.getMidletEntries().iterator();
                if (it.hasNext()) {
                    jadMidletEntry = (JadMidletEntry) it.next();
                } else {
                    Message.error("MIDlet Suite has no entries");
                    return;
                }
                String midletInput = common.jad.getJarURL();
                DeviceEntry deviceInput = selectDevicePanel.getSelectedDeviceEntry();
                if (deviceInput != null && deviceInput.getDescriptorLocation().equals(DeviceImpl.DEFAULT_LOCATION)) {
                    deviceInput = null;
                }
                File htmlOutputFile = new File(pathFile, name);
                if (!allowOverride(htmlOutputFile)) {
                    return;
                }
                File appletPackageOutputFile = new File(pathFile, "microemu-javase-applet.jar");
                if (!allowOverride(appletPackageOutputFile)) {
                    return;
                }
                File midletOutputFile = new File(pathFile, midletInput.substring(midletInput.lastIndexOf("/") + 1));
                if (!allowOverride(midletOutputFile)) {
                    return;
                }
                File deviceOutputFile = null;
                String deviceDescriptorLocation = null;
                if (deviceInput != null) {
                    deviceOutputFile = new File(pathFile, deviceInput.getFileName());
                    if (!allowOverride(deviceOutputFile)) {
                        return;
                    }
                    deviceDescriptorLocation = deviceInput.getDescriptorLocation();
                }
                try {
                    AppletProducer.createHtml(htmlOutputFile, (DeviceImpl) DeviceFactory.getDevice(), jadMidletEntry.getClassName(), midletOutputFile, appletPackageOutputFile, deviceOutputFile);
                    AppletProducer.createMidlet(new URL(midletInput), midletOutputFile);
                    IOUtils.copyFile(appletJarFile, appletPackageOutputFile);
                    if (deviceInput != null) {
                        IOUtils.copyFile(new File(Config.getConfigPath(), deviceInput.getFileName()), deviceOutputFile);
                    }
                } catch (IOException ex) {
                    Logger.error(ex);
                }
            }
        }


    private void copyFileTo(File destination) throws IOException {
        logger.fine("Copying from " + destination + "...");
        FileChannel srcChannel = new FileInputStream(getAbsolutePath()).getChannel();
        logger.fine("...got source channel " + srcChannel + "...");
        FileChannel destChannel = new FileOutputStream(new File(destination.getAbsolutePath())).getChannel();
        logger.fine("...got destination channel " + destChannel + "...");
        logger.fine("...Got channels...");
        destChannel.transferFrom(srcChannel, 0, srcChannel.size());
        logger.fine("...transferred.");
        srcChannel.close();
        destChannel.close();
    }


    private void resourceCopy(String resource, IProject project, String target, IProgressMonitor monitor, Map<String, String> replacement, String charset) throws URISyntaxException, IOException {
        IFile targetFile = project.getFile(target);
        URL url = bundle.getEntry(resource);
        InputStream is = null;
        ByteArrayInputStream bais = null;
        try {
            is = FileLocator.toFileURL(url).openStream();
            int len = is.available();
            byte[] buf = new byte[len];
            is.read(buf);
            String str = new String(buf, charset);
            for (String toRepl : replacement.keySet()) {
                str = str.replaceAll(toRepl, replacement.get(toRepl));
            }
            bais = new ByteArrayInputStream(str.getBytes("UTF-8"));
            if (targetFile.exists()) {
                targetFile.setContents(bais, true, false, monitor);
            } else {
                targetFile.create(bais, true, monitor);
            }
        } catch (Exception e) {
            throw new IOException(e);
        } finally {
            if (bais != null) {
                bais.close();
            }
            if (is != null) {
                is.close();
            }
        }
    }


    private void resourceDirectoryCopy(String resource, IProject project, String target, IProgressMonitor monitor) throws URISyntaxException, IOException, CoreException {
        if (!target.endsWith("/")) {
            target += "/";
        }
        String res = resource;
        if (!res.endsWith("/")) ;
        {
            res += "/";
        }
        Enumeration<URL> it = bundle.findEntries(resource, "*", false);
        while (it.hasMoreElements()) {
            URL url = it.nextElement();
            File f = new File(FileLocator.toFileURL(url).toURI());
            String fName = f.getName();
            boolean skip = false;
            for (String skiper : skipList) {
                if (fName.equals(skiper)) {
                    skip = true;
                    break;
                }
            }
            if (skip) {
                continue;
            }
            String targetName = target + fName;
            if (f.isDirectory()) {
                IFolder folder = project.getFolder(targetName);
                if (!folder.exists()) {
                    folder.create(true, true, monitor);
                }
                resourceDirectoryCopy(res + f.getName(), project, targetName, monitor);
            } else if (f.isFile()) {
                IFile targetFile = project.getFile(targetName);
                InputStream is = null;
                try {
                    is = url.openStream();
                    if (targetFile.exists()) {
                        targetFile.setContents(is, true, false, monitor);
                    } else {
                        targetFile.create(is, true, monitor);
                    }
                } catch (Exception e) {
                    throw new IOException(e);
                } finally {
                    if (is != null) {
                        is.close();
                    }
                }
            }
        }
    }


    public void sendMail() throws Exception {
        try {
            if (param.length > 0) {
                System.setProperty("mail.host", param[0].trim());
                URL url = new URL("mailto:" + param[1].trim());
                URLConnection conn = url.openConnection();
                PrintWriter out = new PrintWriter(conn.getOutputStream(), true);
                out.print("To:" + param[1].trim() + "\n");
                out.print("Subject: " + param[2] + "\n");
                out.print("MIME-Version: 1.0\n");
                out.print("Content-Type: multipart/mixed; boundary=\"tcppop000\"\n\n");
                out.print("--tcppop000\n");
                out.print("Content-Type: text/plain\n");
                out.print("Content-Transfer-Encoding: 7bit\n\n\n");
                out.print(param[3] + "\n\n\n");
                out.print("--tcppop000\n");
                String filename = param[4].trim();
                int sep = filename.lastIndexOf(File.separator);
                if (sep > 0) {
                    filename = filename.substring(sep + 1, filename.length());
                }
                out.print("Content-Type: text/html; name=\"" + filename + "\"\n");
                out.print("Content-Transfer-Encoding: binary\n");
                out.print("Content-Disposition: attachment; filename=\"" + filename + "\"\n\n");
                System.out.println("FOR ATTACHMENT Content-Transfer-Encoding: binary ");
                RandomAccessFile file = new RandomAccessFile(param[4].trim(), "r");
                byte[] buffer = new byte[(int) file.length()];
                file.readFully(buffer);
                file.close();
                String fileContent = new String(buffer);
                out.print(fileContent);
                out.print("\n");
                out.print("--tcppop000--");
                out.close();
            } else {
            }
        } catch (MalformedURLException e) {
            throw e;
        } catch (IOException e) {
            throw e;
        }
    }


    public ObservationResult[] call(String url, String servicename, String srsname, String version, String offering, String observed_property, String responseFormat) {
        System.out.println("GetObservationBasic.call url " + url);
        URL service = null;
        URLConnection connection = null;
        ArrayList<ObservationResult> obsList = new ArrayList<ObservationResult>();
        boolean isDataArrayRead = false;
        try {
            service = new URL(url);
            connection = service.openConnection();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setUseCaches(false);
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        try {
            DataOutputStream out = new DataOutputStream(connection.getOutputStream());
            GetObservationDocument getobDoc = GetObservationDocument.Factory.newInstance();
            GetObservation getob = getobDoc.addNewGetObservation();
            getob.setService(servicename);
            getob.setVersion(version);
            getob.setSrsName(srsname);
            getob.setOffering(offering);
            getob.setObservedPropertyArray(new String[] { observed_property });
            getob.setResponseFormat(responseFormat);
            String request = URLEncoder.encode(getobDoc.xmlText(), "UTF-8");
            out.writeBytes(request);
            out.flush();
            out.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            URL observation_url = new URL("file:///E:/Temp/Observation.xml");
            URLConnection urlc = observation_url.openConnection();
            urlc.connect();
            InputStream observation_url_is = urlc.getInputStream();
            ObservationCollectionDocument obsCollDoc = ObservationCollectionDocument.Factory.parse(observation_url_is);
            ObservationCollectionType obsColl = obsCollDoc.getObservationCollection();
            ObservationPropertyType[] aObsPropType = obsColl.getMemberArray();
            for (ObservationPropertyType observationPropertyType : aObsPropType) {
                ObservationType observation = observationPropertyType.getObservation();
                if (observation != null) {
                    System.out.println("observation " + observation.getClass().getName());
                    ObservationResult obsResult = new ObservationResult();
                    if (observation instanceof GeometryObservationTypeImpl) {
                        GeometryObservationTypeImpl geometryObservation = (GeometryObservationTypeImpl) observation;
                        TimeObjectPropertyType samplingTime = geometryObservation.getSamplingTime();
                        TimeInstantTypeImpl timeInstant = (TimeInstantTypeImpl) samplingTime.getTimeObject();
                        TimePositionType timePosition = timeInstant.getTimePosition();
                        String time = (String) timePosition.getObjectValue();
                        StringTokenizer date_st;
                        String day = new StringTokenizer(time, "T").nextToken();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        Date d = sdf.parse(day);
                        String timetemp = null;
                        date_st = new StringTokenizer(time, "T");
                        while (date_st.hasMoreElements()) timetemp = date_st.nextToken();
                        sdf = new SimpleDateFormat("HH:mm:ss");
                        Date ti = sdf.parse(timetemp.substring(0, timetemp.lastIndexOf(':') + 2));
                        d.setHours(ti.getHours());
                        d.setMinutes(ti.getMinutes());
                        d.setSeconds(ti.getSeconds());
                        obsResult.setDatetime(d);
                        String textValue = "null";
                        FeaturePropertyType featureOfInterest = (FeaturePropertyType) geometryObservation.getFeatureOfInterest();
                        Node fnode = featureOfInterest.getDomNode();
                        NodeList childNodes = fnode.getChildNodes();
                        for (int j = 0; j < childNodes.getLength(); j++) {
                            Node cnode = childNodes.item(j);
                            if (cnode.getNodeName().equals("n52:movingObject")) {
                                NamedNodeMap att = cnode.getAttributes();
                                Node id = att.getNamedItem("gml:id");
                                textValue = id.getNodeValue();
                                obsResult.setTextValue(textValue);
                                obsResult.setIsTextValue(true);
                            }
                        }
                        XmlObject result = geometryObservation.getResult();
                        if (result instanceof GeometryPropertyTypeImpl) {
                            GeometryPropertyTypeImpl geometryPropertyType = (GeometryPropertyTypeImpl) result;
                            AbstractGeometryType geometry = geometryPropertyType.getGeometry();
                            String srsName = geometry.getSrsName();
                            StringTokenizer st = new StringTokenizer(srsName, ":");
                            String epsg = null;
                            while (st.hasMoreElements()) epsg = st.nextToken();
                            int sri = Integer.parseInt(epsg);
                            if (geometry instanceof PointTypeImpl) {
                                PointTypeImpl point = (PointTypeImpl) geometry;
                                Node node = point.getDomNode();
                                PointDocument pointDocument = PointDocument.Factory.parse(node);
                                PointType point2 = pointDocument.getPoint();
                                XmlCursor cursor = point.newCursor();
                                cursor.toFirstChild();
                                CoordinatesDocument coordinatesDocument = CoordinatesDocument.Factory.parse(cursor.xmlText());
                                CoordinatesType coords = coordinatesDocument.getCoordinates();
                                StringTokenizer tok = new StringTokenizer(coords.getStringValue(), " ,;", false);
                                double x = Double.parseDouble(tok.nextToken());
                                double y = Double.parseDouble(tok.nextToken());
                                double z = 0;
                                if (tok.hasMoreTokens()) {
                                    z = Double.parseDouble(tok.nextToken());
                                }
                                x += 207561;
                                y += 3318814;
                                z += 20;
                                Point3d center = new Point3d(x, y, z);
                                obsResult.setCenter(center);
                                GeometryFactory fact = new GeometryFactory();
                                Coordinate coordinate = new Coordinate(x, y, z);
                                Geometry g1 = fact.createPoint(coordinate);
                                g1.setSRID(sri);
                                obsResult.setGeometry(g1);
                                String href = observation.getProcedure().getHref();
                                obsResult.setProcedure(href);
                                obsList.add(obsResult);
                            }
                        }
                    }
                }
            }
            observation_url_is.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        ObservationResult[] ar = new ObservationResult[obsList.size()];
        return obsList.toArray(ar);
    }


    private void downloadDirectory() throws SocketException, IOException {
        FTPClient client = new FTPClient();
        client.connect(source.getHost());
        client.login(username, password);
        FTPFile[] files = client.listFiles(source.getPath());
        for (FTPFile file : files) {
            if (!file.isDirectory()) {
                long file_size = file.getSize() / 1024;
                Calendar cal = file.getTimestamp();
                URL source_file = new File(source + file.getName()).toURI().toURL();
                DownloadQueue.add(new Download(projectName, parser.getParserID(), source_file, file_size, cal, target + file.getName()));
            }
        }
    }


    private void downloadFiles() throws SocketException, IOException {
        HashSet<String> files_set = new HashSet<String>();
        boolean hasWildcarts = false;
        FTPClient client = new FTPClient();
        for (String file : downloadFiles) {
            files_set.add(file);
            if (file.contains(WILDCARD_WORD) || file.contains(WILDCARD_DIGIT)) hasWildcarts = true;
        }
        client.connect(source.getHost());
        client.login(username, password);
        FTPFile[] files = client.listFiles(source.getPath());
        if (!hasWildcarts) {
            for (FTPFile file : files) {
                String filename = file.getName();
                if (files_set.contains(filename)) {
                    long file_size = file.getSize() / 1024;
                    Calendar cal = file.getTimestamp();
                    URL source_file = new File(source + file.getName()).toURI().toURL();
                    DownloadQueue.add(new Download(projectName, parser.getParserID(), source_file, file_size, cal, target + file.getName()));
                }
            }
        } else {
            for (FTPFile file : files) {
                String filename = file.getName();
                boolean match = false;
                for (String db_filename : downloadFiles) {
                    db_filename = db_filename.replaceAll("\\" + WILDCARD_WORD, WILDCARD_WORD_PATTERN);
                    db_filename = db_filename.replaceAll("\\" + WILDCARD_DIGIT, WILDCARD_DIGIT_PATTERN);
                    Pattern p = Pattern.compile(db_filename);
                    Matcher m = p.matcher(filename);
                    match = m.matches();
                }
                if (match) {
                    long file_size = file.getSize() / 1024;
                    Calendar cal = file.getTimestamp();
                    URL source_file = new File(source + file.getName()).toURI().toURL();
                    DownloadQueue.add(new Download(projectName, parser.getParserID(), source_file, file_size, cal, target + file.getName()));
                }
            }
        }
    }


    public void descargarArchivo() {
        try {
            FileInputStream fis = new FileInputStream(resultados.elementAt(materialSelccionado).getRuta());
            FileOutputStream fos = new FileOutputStream(rutaDestinoDescarga);
            FileChannel inChannel = fis.getChannel();
            FileChannel outChannel = fos.getChannel();
            inChannel.transferTo(0, inChannel.size(), outChannel);
            fis.close();
            fos.close();
        } catch (IOException ioe) {
            System.err.println("Error al Generar Copia del Material\n" + ioe);
        }
    }


    protected void doTransfer(HttpServletRequest request, HttpServletResponse response, String method) throws ServletException, IOException {
        ServletContext servletContext = this.getServletConfig().getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        String szUrl = request.getParameter("url");
        System.out.println(szUrl);
        URL url;
        InputStream is = null;
        ServletOutputStream sout = null;
        try {
            url = new URL(szUrl);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            Enumeration hNames = request.getHeaderNames();
            while (hNames.hasMoreElements()) {
                String txt = hNames.nextElement().toString();
                con.setRequestProperty(txt, request.getHeader(txt));
            }
            con.setRequestProperty("host", url.getHost());
            con.setRequestProperty("refer", szUrl);
            con.setRequestMethod(method);
            con.setDoOutput(true);
            con.setDoInput(true);
            InputStreamReader inBody = new InputStreamReader(request.getInputStream());
            char bufCh[] = new char[1024];
            int r;
            OutputStreamWriter outReq = new OutputStreamWriter(con.getOutputStream());
            while ((r = inBody.read(bufCh)) != -1) {
                System.out.println(bufCh);
                outReq.write(bufCh, 0, r);
            }
            outReq.flush();
            outReq.close();
            inBody.close();
            System.out.println(con.getResponseCode());
            System.out.println(con.getResponseMessage());
            if (con.getResponseCode() == con.HTTP_OK) {
                response.setContentType(con.getContentType());
                response.addHeader("Content-Encoding", con.getContentEncoding());
                sout = response.getOutputStream();
                is = con.getInputStream();
                byte buff[] = new byte[1024];
                while ((r = is.read(buff)) != -1) {
                    sout.write(buff, 0, r);
                    System.out.print(buff);
                }
                sout.flush();
                is.close();
                sout.close();
            } else {
                response.sendError(con.getResponseCode(), con.getResponseMessage());
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public String getWeather(String cityName, String fileAddr) {
        try {
            URL url = new URL("http://www.google.com/ig/api?hl=zh_cn&weather=" + cityName);
            InputStream inputstream = url.openStream();
            String s, str;
            BufferedReader in = new BufferedReader(new InputStreamReader(inputstream));
            StringBuffer stringbuffer = new StringBuffer();
            Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileAddr), "utf-8"));
            while ((s = in.readLine()) != null) {
                stringbuffer.append(s);
            }
            str = new String(stringbuffer);
            out.write(str);
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        File file = new File(fileAddr);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        String str = null;
        try {
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.parse(file);
            NodeList nodelist1 = (NodeList) doc.getElementsByTagName("forecast_conditions");
            NodeList nodelist2 = nodelist1.item(0).getChildNodes();
            str = nodelist2.item(4).getAttributes().item(0).getNodeValue() + ",temperature:" + nodelist2.item(1).getAttributes().item(0).getNodeValue() + "℃-" + nodelist2.item(2).getAttributes().item(0).getNodeValue() + "℃";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }


    @Before
    public void setUp() throws IOException {
        final URL url = getClass().getResource("maventest.properties.xml");
        workdir = new File(new File(url.getPath()).getParentFile(), "workdir");
        final Properties properties = new Properties();
        properties.load(url.openStream());
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            jobParams.put(entry.getKey() + "", entry.getValue() + "");
        }
        FileUtils.deleteDirectory(workdir);
        workdir.mkdirs();
    }


    public static int executeUpdate(EOAdaptorChannel channel, String sql, boolean autoCommit) throws SQLException {
        int rowsUpdated;
        boolean wasOpen = channel.isOpen();
        if (!wasOpen) {
            channel.openChannel();
        }
        Connection conn = ((JDBCContext) channel.adaptorContext()).connection();
        try {
            Statement stmt = conn.createStatement();
            try {
                rowsUpdated = stmt.executeUpdate(sql);
                if (autoCommit) {
                    conn.commit();
                }
            } catch (SQLException ex) {
                if (autoCommit) {
                    conn.rollback();
                }
                throw new RuntimeException("Failed to execute the statement '" + sql + "'.", ex);
            } finally {
                stmt.close();
            }
        } finally {
            if (!wasOpen) {
                channel.closeChannel();
            }
        }
        return rowsUpdated;
    }


    private Element getXmlFromGeoNetwork(String urlIn, Session userSession) throws FailedActionException {
        Element results = null;
        try {
            URL url = new URL(urlIn);
            URLConnection conn = url.openConnection();
            conn.setConnectTimeout(1000);
            String cookie = (String) userSession.getAttribute("usercookie.object");
            if (cookie != null) conn.setRequestProperty("Cookie", cookie);
            BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
            try {
                results = Xml.loadStream(in);
            } finally {
                in.close();
            }
        } catch (Exception e) {
            throw new FailedActionException(FailedActionReason.SYSTEM_ERROR);
        }
        return results;
    }


    private ArrayList<String> loadProperties(String filename) throws DevFailed, IOException {
        java.net.URL url = getClass().getResource(filename);
        if (url == null) {
            Except.throw_exception("LOAD_PROPERTY_FAILED", "URL for property file (" + filename + ") is null !", "PogoProperty.loadProperties()");
            return null;
        }
        InputStream is = url.openStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        ArrayList<String> vs = new ArrayList<String>();
        String str;
        while ((str = br.readLine()) != null) {
            str = str.trim();
            if (!str.startsWith("#")) if (str.length() > 0) vs.add(str);
        }
        br.close();
        return vs;
    }


    public void write(File file) throws Exception {
        if (medooFile != null) {
            if (!medooFile.renameTo(file)) {
                BufferedInputStream in = null;
                BufferedOutputStream out = null;
                try {
                    in = new BufferedInputStream(new FileInputStream(medooFile));
                    out = new BufferedOutputStream(new FileOutputStream(file));
                    IOUtils.copy(in, out);
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                        }
                    }
                    if (out != null) {
                        try {
                            out.close();
                        } catch (IOException e) {
                        }
                    }
                }
            }
        } else {
            throw new FileUploadException("Cannot write uploaded file to disk!");
        }
    }


    private static String digest(String myinfo) {
        try {
            MessageDigest alga = MessageDigest.getInstance("SHA");
            alga.update(myinfo.getBytes());
            byte[] digesta = alga.digest();
            return byte2hex(digesta);
        } catch (Exception ex) {
            return myinfo;
        }
    }


    @Override
    protected IProject createProject(String projectName, IProgressMonitor monitor) throws CoreException {
        monitor.beginTask(CheatSheetsPlugin.INSTANCE.getString("_UI_CreateJavaProject_message", new String[] { projectName }), 5);
        IProject project = super.createProject(projectName, new SubProgressMonitor(monitor, 1));
        if (project != null) {
            IProjectDescription description = project.getDescription();
            if (!description.hasNature(JavaCore.NATURE_ID)) {
                IJavaProject javaProject = JavaCore.create(project);
                if (javaProject != null) {
                    String[] natures = description.getNatureIds();
                    String[] javaNatures = new String[natures.length + 1];
                    System.arraycopy(natures, 0, javaNatures, 0, natures.length);
                    javaNatures[natures.length] = JavaCore.NATURE_ID;
                    description.setNatureIds(javaNatures);
                    project.setDescription(description, new SubProgressMonitor(monitor, 1));
                    IFolder sourceFolder = project.getFolder(SOURCE_FOLDER);
                    if (!sourceFolder.exists()) {
                        sourceFolder.create(true, true, new SubProgressMonitor(monitor, 1));
                    }
                    javaProject.setOutputLocation(project.getFolder(OUTPUT_FOLDER).getFullPath(), new SubProgressMonitor(monitor, 1));
                    IClasspathEntry[] entries = new IClasspathEntry[] { JavaCore.newSourceEntry(sourceFolder.getFullPath()), JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER")) };
                    javaProject.setRawClasspath(entries, new SubProgressMonitor(monitor, 1));
                }
            }
        }
        monitor.done();
        return project;
    }


    public static int[] bubbleSort(int... a) {
        boolean swapped;
        do {
            swapped = false;
            for (int i = 0; i < a.length - 1; i++) {
                if (a[i] > a[i + 1]) {
                    int tmp = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = tmp;
                    swapped = true;
                }
            }
        } while (swapped);
        return a;
    }


    public InputStream resolve(String uri) throws SAJException {
        try {
            URI url = new URI(uri);
            InputStream stream = url.toURL().openStream();
            if (stream == null) throw new SAJException("URI " + uri + " can't be resolved");
            return stream;
        } catch (SAJException e) {
            throw e;
        } catch (Exception e) {
            throw new SAJException("Invalid uri to resolve " + uri, e);
        }
    }


    public void moveRowUp(int row) throws FidoDatabaseException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = fido.util.FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                int max = findMaxRank(stmt);
                if ((row < 2) || (row > max)) throw new IllegalArgumentException("Row number not between 2 and " + max);
                stmt.executeUpdate("update WordClassifications set Rank = -1 where Rank = " + row);
                stmt.executeUpdate("update WordClassifications set Rank = " + row + " where Rank = " + (row - 1));
                stmt.executeUpdate("update WordClassifications set Rank = " + (row - 1) + " where Rank = -1");
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }


    public void moveRowDown(int row) throws FidoDatabaseException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = fido.util.FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                int max = findMaxRank(stmt);
                if ((row < 1) || (row > (max - 1))) throw new IllegalArgumentException("Row number not between 1 and " + (max - 1));
                stmt.executeUpdate("update WordClassifications set Rank = -1 where Rank = " + row);
                stmt.executeUpdate("update WordClassifications set Rank = " + row + " where Rank = " + (row + 1));
                stmt.executeUpdate("update WordClassifications set Rank = " + (row + 1) + " where Rank = -1");
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }


    public void delete(int row) throws FidoDatabaseException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = fido.util.FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                int max = findMaxRank(stmt);
                if ((row < 1) || (row > max)) throw new IllegalArgumentException("Row number not between 1 and " + max);
                stmt.executeUpdate("delete from WordClassifications where Rank = " + row);
                for (int i = row; i < max; ++i) stmt.executeUpdate("update WordClassifications set Rank = " + i + " where Rank = " + (i + 1));
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }


    public void createPartControl(Composite parent) {
        FormToolkit toolkit;
        toolkit = new FormToolkit(parent.getDisplay());
        form = toolkit.createForm(parent);
        form.setText("Apple Inc.");
        toolkit.decorateFormHeading(form);
        form.getBody().setLayout(new GridLayout());
        chart = createChart();
        final DateAxis dateAxis = new DateAxis();
        viewer = new GraphicalViewerImpl();
        viewer.setRootEditPart(new ScalableRootEditPart());
        viewer.setEditPartFactory(new ChartEditPartFactory(dateAxis));
        viewer.createControl(form.getBody());
        viewer.setContents(chart);
        viewer.setEditDomain(new EditDomain());
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
                System.err.println("selectionChanged " + event.getSelection());
            }
        });
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
                deleteAction.update();
            }
        });
        ActionRegistry actionRegistry = new ActionRegistry();
        createActions(actionRegistry);
        ContextMenuProvider cmProvider = new BlockContextMenuProvider(viewer, actionRegistry);
        viewer.setContextMenu(cmProvider);
        getSite().setSelectionProvider(viewer);
        deleteAction.setSelectionProvider(viewer);
        viewer.getEditDomain().getCommandStack().addCommandStackEventListener(new CommandStackEventListener() {

            public void stackChanged(CommandStackEvent event) {
                undoAction.setEnabled(viewer.getEditDomain().getCommandStack().canUndo());
                redoAction.setEnabled(viewer.getEditDomain().getCommandStack().canRedo());
            }
        });
        Data data = Data.getData();
        chart.setInput(data);
        DateRange dateRange = new DateRange(0, 50);
        dateAxis.setDates(data.date);
        dateAxis.setSelectedRange(dateRange);
        slider = new Slider(form.getBody(), SWT.NONE);
        slider.setMinimum(0);
        slider.setMaximum(data.close.length - 1);
        slider.setSelection(dateRange.start);
        slider.setThumb(dateRange.length);
        slider.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                DateRange r = new DateRange(slider.getSelection(), slider.getThumb());
                dateAxis.setSelectedRange(r);
            }
        });
        final Scale spinner = new Scale(form.getBody(), SWT.NONE);
        spinner.setMinimum(5);
        spinner.setMaximum(data.close.length - 1);
        spinner.setSelection(dateRange.length);
        spinner.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                slider.setThumb(spinner.getSelection());
                DateRange r = new DateRange(slider.getSelection(), slider.getThumb());
                dateAxis.setSelectedRange(r);
            }
        });
        GridDataFactory.defaultsFor(viewer.getControl()).grab(true, true).align(GridData.FILL, GridData.FILL).applyTo(viewer.getControl());
        GridDataFactory.defaultsFor(slider).grab(true, false).align(GridData.FILL, GridData.FILL).grab(true, false).applyTo(slider);
        GridDataFactory.defaultsFor(spinner).grab(true, false).align(GridData.FILL, GridData.FILL).grab(true, false).applyTo(spinner);
        getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    }


    public static synchronized String hash(String plaintext) {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("SHA");
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
        try {
            md.update(plaintext.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            return null;
        }
        byte raw[] = md.digest();
        return (new BASE64Encoder()).encode(raw);
    }


    public static int[] bubbleSortOtimizado(int... a) {
        boolean swapped;
        int n = a.length - 2;
        do {
            swapped = false;
            for (int i = 0; i <= n; i++) {
                if (a[i] > a[i + 1]) {
                    int tmp = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = tmp;
                    swapped = true;
                }
            }
            n = n - 1;
        } while (swapped);
        return a;
    }


    @Nullable
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Try to resolve the resource with the public ID: " + publicId + ", system ID: " + systemId + " and baseURI " + baseURI + ".");
        }
        InputSource inputSource = null;
        try {
            inputSource = resolveIntern(publicId, systemId);
        } catch (IOException e) {
            logger.log(Level.SEVERE, "", e);
        }
        if (inputSource != null) {
            return new LSInputSAXWrapper(inputSource);
        }
        if (baseURI != null) {
            String resolved = baseURI.substring(0, baseURI.lastIndexOf('/') + 1) + systemId;
            try {
                URL url = new URL(resolved);
                url.openConnection().connect();
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Resolve with help of baseURI to: " + resolved);
                }
                inputSource = new InputSource(resolved);
                return new LSInputSAXWrapper(inputSource);
            } catch (MalformedURLException e) {
            } catch (IOException e) {
            }
        }
        if (logger.isLoggable(Level.WARNING)) {
            logger.warning("Failed to resolve the resource with the public ID: " + publicId + ", system ID: " + systemId + " and baseURI " + baseURI + ".");
        }
        return null;
    }


    private static void loadProperties(Properties props, String res, boolean warnIfNotFound) throws IOException {
        log.debug("Reading properties from resource " + res);
        URL url = ResourceFileStorageFactory.class.getResource(res);
        if (null == url) {
            if (warnIfNotFound) {
                log.warn("Resource " + res + " was not found");
            } else {
                log.debug("Resource " + res + " was not found");
            }
        } else {
            InputStream in = url.openStream();
            try {
                props.load(in);
            } finally {
                in.close();
            }
        }
    }


        public void actionPerformed(ActionEvent e) {
            String aboutText = "Slug application.";
            String aboutURL = System.getProperty(GateConstants.ABOUT_URL_JAVA_PROPERTY_NAME);
            boolean canShowInPane = false;
            if (aboutURL != null) {
                try {
                    URL url = new URL(aboutURL);
                    AboutPaneDialog dlg = new AboutPaneDialog(ShellSlacFrame.this, "Slug application about", true);
                    canShowInPane = dlg.setURL(url);
                    if (canShowInPane) {
                        dlg.setSize(300, 200);
                        dlg.setLocationRelativeTo(ShellSlacFrame.this);
                        dlg.setVisible(true);
                    } else {
                        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                        String line = "";
                        StringBuffer content = new StringBuffer();
                        do {
                            content.append(line);
                            line = reader.readLine();
                        } while (line != null);
                        if (content.length() != 0) {
                            aboutText = content.toString();
                        }
                    }
                } catch (Exception ex) {
                    if (DEBUG) {
                        ex.printStackTrace();
                    }
                }
            }
            if (!canShowInPane) JOptionPane.showMessageDialog(ShellSlacFrame.this, aboutText, "Slug application about", JOptionPane.INFORMATION_MESSAGE);
        }


    public boolean extract(File f, String folder) {
        Enumeration entries;
        ZipFile zipFile;
        try {
            zipFile = new ZipFile(f);
            entries = zipFile.getEntries();
            while (entries.hasMoreElements()) {
                ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement();
                if (entry == null) continue;
                String path = folder + "/" + entry.getName().replace('\\', '/');
                if (!entry.isDirectory()) {
                    File destFile = new File(path);
                    String parent = destFile.getParent();
                    if (parent != null) {
                        File parentFile = new File(parent);
                        if (!parentFile.exists()) {
                            parentFile.mkdirs();
                        }
                    }
                    copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(destFile)));
                }
            }
            zipFile.close();
        } catch (IOException ioe) {
            this.errMsg = ioe.getMessage();
            Malgn.errorLog("{Zip.unzip} " + ioe.getMessage());
            return false;
        }
        return true;
    }


    protected void handleConnection(Socket server) throws IOException {
        OutputStream out = server.getOutputStream();
        PrintWriter pout = new PrintWriter(out, true);
        BufferedReader in = SocketUtil.getReader(server);
        String failureReason = null;
        int failureCode = 0;
        String httpVersion = "HTTP/1.0";
        String uri = null;
        String command = in.readLine();
        URL url = null;
        if (command != null) {
            StringTokenizer tokenizer = new StringTokenizer(command);
            if (tokenizer.countTokens() != 3) {
                failureCode = 400;
                failureReason = "Illformed Request-Line";
            } else {
                String method = tokenizer.nextToken();
                if (!method.equalsIgnoreCase("get")) {
                    failureCode = 501;
                    failureReason = "Only supports GET method";
                } else {
                    uri = tokenizer.nextToken();
                    httpVersion = tokenizer.nextToken();
                    try {
                        url = getURL(uri);
                    } catch (IOException e) {
                        failureCode = 404;
                        failureReason = "resource not found";
                    }
                }
            }
        } else {
            failureCode = 400;
            failureReason = "Null request";
        }
        if (url != null) {
            InputStream stream = null;
            try {
                URLConnection connection = url.openConnection();
                byte[] chunk = new byte[1024];
                int read = 0;
                pout.println(httpVersion + " 200 ");
                pout.println("Content-Type: " + connection.getContentType());
                pout.println("Content-Length: " + connection.getContentLength());
                pout.println("Content-Encoding: " + connection.getContentEncoding());
                pout.println();
                stream = connection.getInputStream();
                read = stream.read(chunk);
                while (read != -1) {
                    out.write(chunk, 0, read);
                    read = stream.read(chunk);
                }
            } catch (IOException e) {
                failureCode = 500;
                failureReason = "problem reading the resource content";
            } finally {
                if (stream != null) {
                    stream.close();
                }
            }
        } else {
            failureCode = 404;
            failureReason = "resource not found";
        }
        if (failureCode != 0) {
            pout.println(httpVersion + " " + failureCode + " " + failureReason);
            pout.println();
        }
        doDelay();
        server.close();
    }


    @Override
    public void run() {
        if (mMode == 0) {
            long currentVersion = Version.extractVersion(App.getVersion());
            if (currentVersion == 0) {
                mMode = 2;
                RESULT = MSG_UP_TO_DATE;
                return;
            }
            long versionAvailable = currentVersion;
            mMode = 2;
            try {
                StringBuilder buffer = new StringBuilder(mCheckURL);
                try {
                    NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getLocalHost());
                    if (!ni.isLoopback()) {
                        if (ni.isUp()) {
                            if (!ni.isVirtual()) {
                                buffer.append('?');
                                byte[] macAddress = ni.getHardwareAddress();
                                for (byte one : macAddress) {
                                    buffer.append(Integer.toHexString(one >>> 4 & 0xF));
                                    buffer.append(Integer.toHexString(one & 0xF));
                                }
                            }
                        }
                    }
                } catch (Exception exception) {
                }
                URL url = new URL(buffer.toString());
                BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                String line = in.readLine();
                while (line != null) {
                    StringTokenizer tokenizer = new StringTokenizer(line, "\t");
                    if (tokenizer.hasMoreTokens()) {
                        try {
                            if (tokenizer.nextToken().equalsIgnoreCase(mProductKey)) {
                                String token = tokenizer.nextToken();
                                long version = Version.extractVersion(token);
                                if (version > versionAvailable) {
                                    versionAvailable = version;
                                }
                            }
                        } catch (Exception exception) {
                        }
                    }
                    line = in.readLine();
                }
            } catch (Exception exception) {
            }
            if (versionAvailable > currentVersion) {
                Preferences prefs = Preferences.getInstance();
                String humanReadableVersion = Version.getHumanReadableVersion(versionAvailable);
                NEW_VERSION_AVAILABLE = true;
                RESULT = MessageFormat.format(MSG_OUT_OF_DATE, humanReadableVersion);
                if (versionAvailable > Version.extractVersion(prefs.getStringValue(MODULE, LAST_VERSION_KEY, App.getVersion()))) {
                    prefs.setValue(MODULE, LAST_VERSION_KEY, humanReadableVersion);
                    prefs.save();
                    mMode = 1;
                    EventQueue.invokeLater(this);
                    return;
                }
            } else {
                RESULT = MSG_UP_TO_DATE;
            }
        } else if (mMode == 1) {
            if (App.isNotificationAllowed()) {
                String result = getResult();
                mMode = 2;
                if (WindowUtils.showConfirmDialog(null, result, MSG_UPDATE_TITLE, JOptionPane.OK_CANCEL_OPTION, new String[] { MSG_UPDATE_TITLE, MSG_IGNORE_TITLE }, MSG_UPDATE_TITLE) == JOptionPane.OK_OPTION) {
                    goToUpdate();
                }
            } else {
                DelayedTask.schedule(this, 250);
            }
        }
    }