Search in sources :

Example 1 with ZipArchiveException

use of de.janrufmonitor.repository.zip.ZipArchiveException in project janrufmonitor by tbrandt77.

the class GosWizard method performFinish.

public boolean performFinish() {
    Map data = ((GosPage) this.m_pages[0]).getResult();
    String id = (String) data.get("name");
    // descriptor data
    Properties descriptor = new Properties();
    descriptor.setProperty(InstallerConst.DESCRIPTOR_REQUIRED_MAJOR_VERSION, IJAMConst.VERSION_MAJOR);
    descriptor.setProperty(InstallerConst.DESCRIPTOR_REQUIRED_MINOR_VERSION, IJAMConst.VERSION_MINOR);
    descriptor.setProperty(InstallerConst.DESCRIPTOR_REQUIRED_PATCH_VERSION, IJAMConst.VERSION_PATCH);
    descriptor.setProperty(InstallerConst.DESCRIPTOR_TYPE, "repository");
    descriptor.setProperty(InstallerConst.DESCRIPTOR_VERSION, (String) data.get("version"));
    descriptor.setProperty(InstallerConst.DESCRIPTOR_NAME, "mod-rep-" + id.toLowerCase());
    descriptor.setProperty(InstallerConst.DESCRIPTOR_NAMESPACE, "repository." + id);
    descriptor.setProperty(InstallerConst.DESCRIPTOR_RESTART, "true");
    descriptor.setProperty(InstallerConst.DESCRIPTOR_CONSOLE_ENABLED, "true");
    descriptor.setProperty(InstallerConst.DESCRIPTOR_CONFIG_OVERWRITE, "true");
    descriptor.setProperty(InstallerConst.DESCRIPTOR_REMOVE, "false");
    // inf data
    Properties inf = new Properties();
    inf.setProperty("repository.CallerManagerFactory:manager_" + id + ":value", "de.janrufmonitor.repository.DynamicWebCallerManager");
    inf.setProperty("repository.CallerManagerFactory:manager_" + id + ":access", "system");
    inf.setProperty("repository." + id + ":enabled:value", "true");
    inf.setProperty("repository." + id + ":enabled:type", "boolean");
    inf.setProperty("repository." + id + ":usecache:value", "true");
    inf.setProperty("repository." + id + ":usecache:type", "boolean");
    inf.setProperty("repository." + id + ":useragent:value", "Mozilla/4.0 (compatible; MSIE; Windows NT)");
    inf.setProperty("repository." + id + ":useragent:type", "text");
    inf.setProperty("repository." + id + ":priority:value", "10");
    inf.setProperty("repository." + id + ":priority:type", "integer");
    inf.setProperty("repository." + id + ":skipbytes:value", (String) data.get("offset"));
    inf.setProperty("repository." + id + ":skipbytes:type", "integer");
    inf.setProperty("repository." + id + ":url:value", (String) data.get("url"));
    inf.setProperty("repository." + id + ":regexp.lastname:value", (String) data.get("lastname"));
    inf.setProperty("repository." + id + ":regexp.firstname:value", (String) data.get("firstname"));
    inf.setProperty("repository." + id + ":regexp.street:value", (String) data.get("street"));
    inf.setProperty("repository." + id + ":regexp.streetno:value", (String) data.get("streetno"));
    inf.setProperty("repository." + id + ":regexp.pcode:value", (String) data.get("postal"));
    inf.setProperty("repository." + id + ":regexp.city:value", (String) data.get("city"));
    inf.setProperty("repository." + id + ":regexp.areacode:value", (String) data.get("area"));
    inf.setProperty("repository." + id + ":regexp.phone:value", (String) data.get("number"));
    inf.setProperty("repository." + id + ":intareacode:value", (String) data.get("intarea"));
    inf.setProperty("repository." + id + ":locale:value", (String) data.get("locale"));
    inf.setProperty("repository." + id + ":encoding:value", (String) data.get("encoding"));
    inf.setProperty("ui.jface.configuration.ConfigurationCommand:page_" + id + ":value", "de.janrufmonitor.ui.jface.configuration.pages.DynamicWebCallerManager");
    inf.setProperty("ui.jface.configuration.ConfigurationCommand:page_" + id + ":access", "system");
    // i18n data
    Properties i18n = new Properties();
    i18n.setProperty("repository." + id + ":title:label:de", (String) data.get("name"));
    i18n.setProperty("ui.jface.configuration.pages." + id + ":title:label:de", (String) data.get("name"));
    i18n.setProperty("ui.jface.configuration.pages." + id + ":description:label:de", "Dieses Modul identifiziert Anrufe bei bestehender Internetverbindung mit der Online-Telefonauskunft " + (String) data.get("name"));
    i18n.setProperty("ui.jface.configuration.pages." + id + ":enabled:label:de", "Datenablage aktiviert");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":skipbytes:label:de", "Zeichen-Offset: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":url:label:de", "Abfrage-URL: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":intareacode:label:de", "L\u00E4ndercode: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.lastname:label:de", "Muster f\u00FCr Nachname: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.firstname:label:de", "Muster f\u00FCr Vorname: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.street:label:de", "Muster f\u00FCr Strasse: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.streetno:label:de", "Muster f\u00FCr Hausnummer: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.pcode:label:de", "Muster f\u00FCr PLZ: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.city:label:de", "Muster f\u00FCr Stadt: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.areacode:label:de", "Muster f\u00FCr Vorwahl: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":regexp.phone:label:de", "Muster f\u00FCr Rufnummer: ");
    i18n.setProperty("ui.jface.configuration.pages." + id + ":encoding:label:de", "Zeichenkodierung: ");
    Properties i18n_en = new Properties();
    i18n_en.setProperty("repository." + id + ":title:label:en", (String) data.get("name"));
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":title:label:en", (String) data.get("name"));
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":description:label:en", "This module identifies callers with the online service " + (String) data.get("name"));
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":enabled:label:en", "Repository enabled");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":skipbytes:label:en", "Offset: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":url:label:en", "URL: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":intareacode:label:en", "International area code: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.lastname:label:en", "Pattern for lastname: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.firstname:label:en", "Pattern for firstname: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.street:label:en", "Pattern for street: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.streetno:label:en", "Pattern for street no: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.pcode:label:en", "Pattern for postal code: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.city:label:en", "Pattern for city: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.areacode:label:en", "Pattern for areacode: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":regexp.phone:label:en", "Pattern for number: ");
    i18n_en.setProperty("ui.jface.configuration.pages." + id + ":encoding:label:en", "Encoding: ");
    // create jam.zip archive
    File dir = new File((String) data.get("directory"));
    if (!dir.exists()) {
        dir.mkdirs();
    }
    File icon = new File((String) data.get("icon"));
    ZipArchive z = new ZipArchive(dir.getAbsolutePath() + File.separator + "mod-rep-" + id.toLowerCase() + "." + descriptor.getProperty(InstallerConst.DESCRIPTOR_VERSION, "1.0.0") + ".jam.zip");
    try {
        z.open();
        // write descriptor
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        descriptor.store(bos, "");
        bos.flush();
        ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
        z.add("~meta-inf/descriptor.properties", bin);
        // write inf data
        bos = new ByteArrayOutputStream();
        inf.store(bos, "");
        bos.flush();
        bin = new ByteArrayInputStream(bos.toByteArray());
        z.add("install/repository." + id + ".inf", bin);
        // write i18n data
        bos = new ByteArrayOutputStream();
        i18n.store(bos, "");
        bos.flush();
        bin = new ByteArrayInputStream(bos.toByteArray());
        z.add("install/repository." + id + ".i18n", bin);
        // write i18n_en data
        bos = new ByteArrayOutputStream();
        i18n_en.store(bos, "");
        bos.flush();
        bin = new ByteArrayInputStream(bos.toByteArray());
        z.add("install/repository." + id + ".en.i18n", bin);
        if (icon.exists())
            z.add("images/" + id + ".png", new FileInputStream(icon));
        z.close();
        bin.close();
        bos.close();
    } catch (ZipArchiveException e) {
        this.m_logger.severe(e.toString());
    } catch (IOException e) {
        this.m_logger.severe(e.toString());
    }
    return true;
}
Also used : ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) GosPage(de.janrufmonitor.ui.jface.application.gos.wizard.pages.GosPage) ByteArrayInputStream(java.io.ByteArrayInputStream) ZipArchive(de.janrufmonitor.repository.zip.ZipArchive) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Properties(java.util.Properties) Map(java.util.Map) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with ZipArchiveException

use of de.janrufmonitor.repository.zip.ZipArchiveException in project janrufmonitor by tbrandt77.

the class GoogleContactsProxy method start.

public void start() {
    if (this.m_dbh == null) {
        String db_path = PathResolver.getInstance(this.getRuntime()).resolve(PathResolver.getInstance(this.getRuntime()).getDataDirectory() + "google_cache" + File.separator + "google_mapping.db");
        db_path = StringUtils.replaceString(db_path, "\\", "/");
        File db = new File(db_path + ".properties");
        boolean initialize = false;
        if (!db.exists()) {
            initialize = true;
            db.getParentFile().mkdirs();
            try {
                File db_raw = new File(db_path);
                if (!db_raw.exists()) {
                    ZipArchive z = new ZipArchive(db_path);
                    z.open();
                    z.close();
                }
            } catch (ZipArchiveException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        this.m_dbh = new GoogleContactsProxyDatabaseHandler("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:" + db_path, "sa", "", initialize);
        try {
            this.m_dbh.connect();
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        } catch (ClassNotFoundException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
}
Also used : ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) SQLException(java.sql.SQLException) ZipArchive(de.janrufmonitor.repository.zip.ZipArchive) File(java.io.File)

Example 3 with ZipArchiveException

use of de.janrufmonitor.repository.zip.ZipArchiveException in project janrufmonitor by tbrandt77.

the class MacAddressBookProxy method start.

public synchronized void start() {
    if (this.m_dbh == null) {
        String db_path = PathResolver.getInstance(this.getRuntime()).resolve(PathResolver.getInstance(this.getRuntime()).getDataDirectory() + "macab_cache" + File.separator + "macab_mapping.db");
        db_path = StringUtils.replaceString(db_path, "\\", "/");
        File db = new File(db_path + ".properties");
        boolean initialize = false;
        if (!db.exists()) {
            initialize = true;
            db.getParentFile().mkdirs();
            try {
                File db_raw = new File(db_path);
                if (!db_raw.exists()) {
                    ZipArchive z = new ZipArchive(db_path);
                    z.open();
                    z.close();
                }
            } catch (ZipArchiveException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        this.m_dbh = new MacAddressBookProxyDatabaseHandler("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:" + db_path, "sa", "", initialize);
        try {
            this.m_dbh.connect();
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        } catch (ClassNotFoundException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
}
Also used : ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) MacAddressBookProxyDatabaseHandler(de.janrufmonitor.repository.MacAddressBookProxyDatabaseHandler) SQLException(java.sql.SQLException) ZipArchive(de.janrufmonitor.repository.zip.ZipArchive) File(java.io.File)

Example 4 with ZipArchiveException

use of de.janrufmonitor.repository.zip.ZipArchiveException in project janrufmonitor by tbrandt77.

the class ThunderbirdCallerManager method getDatabaseHandler.

private ICallerDatabaseHandler getDatabaseHandler() {
    if (this.m_dbh == null) {
        String db_path = PathResolver.getInstance(this.getRuntime()).resolve(THB_CACHE_PATH + "thb_data_cache.db");
        db_path = StringUtils.replaceString(db_path, "\\", "/");
        File db = new File(db_path + ".properties");
        boolean initialize = false;
        if (!db.exists()) {
            initialize = true;
            db.getParentFile().mkdirs();
            try {
                File db_raw = new File(db_path);
                if (!db_raw.exists()) {
                    ZipArchive z = new ZipArchive(db_path);
                    z.open();
                    z.close();
                }
            } catch (ZipArchiveException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        this.m_dbh = new ThunderbirdCallerManagerHandler("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:" + db_path, "sa", "", initialize);
        this.m_dbh.setCommitCount(Integer.parseInt(m_configuration.getProperty(CFG_COMMIT_COUNT, "10")));
        this.m_dbh.setKeepAlive((m_configuration.getProperty(CFG_KEEP_ALIVE, "true").equalsIgnoreCase("true") ? true : false));
    }
    return this.m_dbh;
}
Also used : ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) ZipArchive(de.janrufmonitor.repository.zip.ZipArchive) File(java.io.File)

Example 5 with ZipArchiveException

use of de.janrufmonitor.repository.zip.ZipArchiveException in project janrufmonitor by tbrandt77.

the class JamCacheMasterClassLoader method insertJarToCache.

private void insertJarToCache(File jar) throws SQLException {
    if (this.m_cacheConnection == null)
        throw new SQLException("Connection to cache not available...");
    Statement stmt = this.m_cacheConnection.createStatement();
    stmt.execute("INSERT INTO jars (jarname, createdate) VALUES('" + jar.getAbsolutePath() + "', '" + jar.lastModified() + "');");
    ZipArchive jr = new ZipArchive(jar, false);
    try {
        if (!jr.available())
            jr.open();
        List entries = jr.list(new FilenameFilter() {

            public boolean accept(File dir, String name) {
                if (name.toLowerCase().endsWith(".properties"))
                    return false;
                if (name.toLowerCase().endsWith(".mf"))
                    return false;
                return true;
            }
        });
        String entry = null;
        byte[] c = null;
        PreparedStatement ps = this.m_cacheConnection.prepareStatement("INSERT INTO classes (classname, jarname, content) VALUES (?,?,?);");
        for (int i = 0, j = entries.size(); i < j; i++) {
            ps.clearParameters();
            entry = (String) entries.get(i);
            c = jr.getContent(entry);
            if (c != null) {
                if (entry.length() > 6 && entry.endsWith(".class"))
                    entry = entry.substring(0, entry.length() - 6);
                if (classNameReplacementChar == '\u0000') {
                    entry = entry.replace('/', '.');
                } else {
                    // Replace '.' with custom char, such as '_'
                    entry = entry.replace(classNameReplacementChar, '.');
                }
                ps.setString(1, entry);
                ps.setString(2, jar.getAbsolutePath());
                ps.setObject(3, c);
                ps.addBatch();
                try {
                    ps.executeBatch();
                    ps.clearBatch();
                } catch (SQLException ex) {
                    m_logger.log(Level.INFO, entry + ": " + ex.toString(), ex);
                }
            }
        }
    } catch (ZipArchiveException e) {
        m_logger.log(Level.SEVERE, e.toString(), e);
    } finally {
        try {
            jr.close();
        } catch (ZipArchiveException e) {
            m_logger.log(Level.SEVERE, e.toString(), e);
        }
    }
    this.m_cacheConnection.commit();
}
Also used : ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) FilenameFilter(java.io.FilenameFilter) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ZipArchive(de.janrufmonitor.repository.zip.ZipArchive) List(java.util.List) PreparedStatement(java.sql.PreparedStatement) File(java.io.File)

Aggregations

ZipArchiveException (de.janrufmonitor.repository.zip.ZipArchiveException)14 ZipArchive (de.janrufmonitor.repository.zip.ZipArchive)13 File (java.io.File)13 SQLException (java.sql.SQLException)7 Properties (java.util.Properties)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileInputStream (java.io.FileInputStream)4 IOException (java.io.IOException)4 List (java.util.List)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 FileNotFoundException (java.io.FileNotFoundException)3 Map (java.util.Map)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 FilenameFilter (java.io.FilenameFilter)2 InputStream (java.io.InputStream)2