Package util.exc

Examples of util.exc.TvBrowserException


      //   or '2003-10-04_de_premiere-1_base_full.prog.gz'
      int channelEnd = fileName.indexOf('_', 14);
      return fileName.substring(14, channelEnd);
    }
    catch (Exception exc) {
      throw new TvBrowserException(DayProgramFile.class, "error.1",
        "Program file name has wrong syntax: {0}", fileName, exc);
    }
  }
View Full Code Here


      int channelEnd = fileName.indexOf('_', 14);
      int levelEnd = fileName.indexOf('_', channelEnd + 1);
      return fileName.substring(channelEnd + 1, levelEnd);
    }
    catch (Exception exc) {
      throw new TvBrowserException(DayProgramFile.class, "error.1",
        "Program file name has wrong syntax: {0}", fileName, exc);
    }
  }
View Full Code Here

    StringBuilder buf = new StringBuilder();
    for (Mirror mirror : oldMirrorArr) {
      buf.append(mirror.getUrl()).append('\n');
    }

    throw new TvBrowserException(caller, "error.2", "No mirror found\ntried following mirrors: ", name, buf.toString());
  }
View Full Code Here

          urls = new URL[] { new File(PLUGIN_DIRECTORY, jarFile.getName()).toURI().toURL() };
          classLoader2 = URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader());
        }
      } catch (MalformedURLException exc) {}
    } catch (MalformedURLException exc) {
      throw new TvBrowserException(getClass(), "error.1",
        "Loading Jar file of a plugin failed: {0}.",
        jarFile.getAbsolutePath(), exc);
    }

    // Get the plugin name
    String pluginName = jarFile.getName();
    if (pluginName.endsWith(".jar")) {
      pluginName = pluginName.substring(0, pluginName.length() - 4);
    }

    boolean isBlockedDataService = false;

    // Create a plugin instance
    try {
      Class pluginClass = classLoader.loadClass(pluginName.toLowerCase() + "." + pluginName);
      Method getVersion = pluginClass.getMethod("getVersion",new Class[0]);
      Version version1 = null;
      try {
        version1 = (Version)getVersion.invoke(pluginClass, new Object[0]);
      } catch (Exception e) {
      }
      if (version1 == null || version1.toString().equals("0.0.0.0")) {
        mLog.warning("Did not load plugin " + pluginName + ", version is too old.");
        return null;
      }

      if(pluginClass.getSuperclass().equals(devplugin.AbstractTvDataService.class) || classLoader2 != null) {
        getVersion = pluginClass.getMethod("getVersion",new Class[0]);
        version1 = (Version)getVersion.invoke(pluginClass, new Object[0]);

        if(pluginClass.getSuperclass().equals(devplugin.AbstractTvDataService.class)) {
          isBlockedDataService = Settings.propBlockedPluginArray.isBlocked(pluginName.toLowerCase() + "." + pluginName, version1);
        }
      }

      if(classLoader2 != null) {
        try {
          Class pluginClass2 = classLoader2.loadClass(pluginName.toLowerCase() + "." + pluginName);
          Method getVersion2 = pluginClass2.getMethod("getVersion",new Class[0]);

          Version version2 = (Version)getVersion2.invoke(pluginClass2, new Object[0]);

          if(version2.compareTo(version1) > 0) {
            return null;
          }
        }catch(Throwable t) {}
      }

      try {
        Method preInstancing = pluginClass.getMethod("preInstancing",new Class[0]);
        preInstancing.invoke(pluginClass,new Object[0]);
      }catch(Throwable ti) {}

      if(!isBlockedDataService) {
        plugin = pluginClass.newInstance();
      }
    }
    catch (Throwable thr) {
      throw new TvBrowserException(getClass(), "error.2",
         "Could not load plugin {0}.", jarFile.getAbsolutePath(), thr);
    }

    return plugin;
  }
View Full Code Here

   */
  final void loadSettings(File userDirectory) throws TvBrowserException {
    try {
      doLoadSettings(userDirectory);
    } catch (RuntimeException exc) {
      throw new TvBrowserException(AbstractPluginProxy.class,

          "error.loading.runtimeException", "The plugin {0} caused an error when loading the plugin settings.", getInfo()
          .getName(), exc);
    }
  }
View Full Code Here

   * @throws TvBrowserException If saving failed.
   */
  final synchronized void saveSettings(File userDirectory, boolean log) throws TvBrowserException {
    // Check whether the plugin is activated
    if (!mIsActivated) {
      throw new TvBrowserException(AbstractPluginProxy.class, "error.saving.notActivated",
          "The plugin {0} can't save its settings, because it is not activated.", getInfo().getName());
    }

    // Try to save the settings
    try {
      doSaveSettings(userDirectory, log);
    } catch (Throwable t) {
      throw new TvBrowserException(AbstractPluginProxy.class, "error.saving.runtimeException",
          "The plugin {0} caused an error when saving the plugin settings.", getInfo().getName(), t);
    }
  }
View Full Code Here

   *
   * @throws TvBrowserException If the plugin is not activated
   */
  protected void assertActivatedState() throws TvBrowserException {
    if (!isActivated()) {
      throw new TvBrowserException(AbstractPluginProxy.class, "error.notActive",
          "It was attempted to call an operation of the inactive plugin {0} that "
          + "may only be called on activated plugins.", getInfo().getName());
    }
  }
View Full Code Here

      try {
        in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(datFile), 0x4000));
        mPlugin.readData(in);
      }
      catch (Throwable thr) {
        throw new TvBrowserException(getClass(), "error.3",
            "Loading data for plugin {0} failed.\n({1})",
            getInfo().getName(), datFile.getAbsolutePath(), thr);
      }
      finally {
        if (in != null) {
          try { in.close(); } catch (IOException exc) {
            // ignore
          }
        }
      }
    }

    // load plugin settings
    BufferedInputStream in = null;
    try {
      if (propFile.exists()) {
        Properties prop = new Properties();
        in = new BufferedInputStream(new FileInputStream(propFile), 0x4000);
        prop.load(in);
        in.close();
        mPlugin.loadSettings(prop);
      } else {
        mPlugin.loadSettings(new Properties());
      }
    }
    catch (Throwable thr) {
      throw new TvBrowserException(getClass(), "error.4",
          "Loading settings for plugin {0} failed.\n({1})",
          getInfo().getName(), propFile.getAbsolutePath(), thr);
    }
    finally {
      if (in != null) {
View Full Code Here

      File datFile = new File(userDirectory, getId() + ".dat");
      datFile.delete();
      tmpDatFile.renameTo(datFile);
    }
    catch(Throwable thr) {
      throw new TvBrowserException(getClass(), "error.5",
          "Saving data for plugin {0} failed.\n({1})",
          getInfo().getName(), tmpDatFile.getAbsolutePath(), thr);
    }

    // save the plugin settings in a temp file
    FileOutputStream fOut = null;
    File tmpPropFile = new File(userDirectory, getId() + ".prop.temp");
    try {
      Properties prop = mPlugin.storeSettings();
      if (prop != null) {
        fOut = new FileOutputStream(tmpPropFile);
        prop.store(fOut, "Settings for plugin " + getInfo().getName());
        fOut.close();
      }

      // Saving succeeded -> Delete the old file and rename the temp file
      File propFile = new File(userDirectory, getId() + ".prop");
      propFile.delete();
      tmpPropFile.renameTo(propFile);
    }
    catch (Throwable thr) {
      throw new TvBrowserException(getClass(), "error.6",
          "Saving settings for plugin {0} failed.\n({1})",
          getInfo().getName(), tmpPropFile.getAbsolutePath(), thr);
    }
    finally {
      if (fOut != null) {
View Full Code Here

          IOUtilities.copy(settingsFile,firstSettingsBackupFile);
        }
      }catch (Exception e) {}

    } catch (IOException exc) {
      throw new TvBrowserException(Settings.class, "error.1",
          "Error when saving settings!\n({0})", settingsFile.getAbsolutePath(),
          exc);
    }

    if(log) {
View Full Code Here

TOP

Related Classes of util.exc.TvBrowserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.