capuchin r68 - trunk/src/libcapuchin
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: capuchin r68 - trunk/src/libcapuchin
- Date: Wed, 12 Mar 2008 17:30:13 +0000 (GMT)
Author: sebp
Date: Wed Mar 12 17:30:13 2008
New Revision: 68
URL: http://svn.gnome.org/viewvc/capuchin?rev=68&view=rev
Log:
* Added RepositoryNotInitializedException
* Added check if repository in initialized in each method that access this.RepoItems
Added:
trunk/src/libcapuchin/RepositoryNotInitializedException.cs
Modified:
trunk/src/libcapuchin/AppObject.cs
trunk/src/libcapuchin/libcapuchin.mdp
Modified: trunk/src/libcapuchin/AppObject.cs
==============================================================================
--- trunk/src/libcapuchin/AppObject.cs (original)
+++ trunk/src/libcapuchin/AppObject.cs Wed Mar 12 17:30:13 2008
@@ -37,8 +37,8 @@
private const int SLEEP_TIME = 500;
private bool disposed = false;
- private int repo_dlid = -1;
-
+ private int repo_dlid = -1;
+
/// <param name="repository_url">URL to repository's XML file</param>
public AppObject (string repository_url)
{
@@ -130,8 +130,13 @@
/// <returns>
/// The name of the application the repository belongs to
/// </returns>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string GetApplicationName ()
{
+ this.RepoInitialized ();
+
return this.ApplicationName;
}
@@ -139,9 +144,14 @@
/// <returns>
/// An array of plugin IDs
/// </returns>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string[] GetAvailablePlugins ()
{
Log.Info("Getting available plugins");
+
+ this.RepoInitialized ();
string[] ids = new string[this.RepoItems.Count];
int c=0;
@@ -163,9 +173,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string[] GetAvailableUpdates (string[][] plugins)
{
Log.Info("Getting updates");
+
+ this.RepoInitialized ();
List<string> updates = new List<string>();
foreach (string[] p in plugins)
@@ -190,10 +205,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public void Install (string plugin_id)
{
Log.Info("Updating plugin with id '{0}'", plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
int dlid = Globals.DLM.DownloadFile(this.RepoItems[plugin_id].Url, this.InstallPath, this.RepoItems[plugin_id].Signature, this.RepoItems[plugin_id].Checksum);
@@ -209,10 +228,15 @@
/// </summary>
/// <param name="tag">A tag</param>
/// <returns>A list of plugin IDs</returns>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string[] GetPluginsWithTag (string tag)
{
Log.Info ("Getting plugins with tag '{0}'", tag);
+ this.RepoInitialized ();
+
tag = tag.Trim().ToLower ();
if (!this.TagToPlugins.ContainsKey (tag)) {
return new string[] {};
@@ -230,10 +254,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string GetPluginName (string plugin_id)
{
Log.Info ("Getting name of plugin '{0}'", plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
return this.RepoItems[plugin_id].Name;
@@ -245,10 +273,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string GetPluginDescription (string plugin_id)
{
Log.Info ("Getting description of plugin '{0}'", plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
return this.RepoItems[plugin_id].Description;
@@ -260,10 +292,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string GetPluginChanges (string plugin_id, string version)
{
Log.Info ("Getting changes in version {0} of plugin '{1}'", version, plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
changelog changes = this.RepoItems[plugin_id].Changelog;
@@ -283,10 +319,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string[] GetPluginTags (string plugin_id)
{
Log.Info("Getting tags for plugin with id '{0}'", plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
string[] tags = this.RepoItems[plugin_id].Tags;
@@ -304,10 +344,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string[] GetPluginAuthor (string plugin_id)
{
Log.Info("Getting author of plugin with id '{0}'", plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
author plugin_author = this.RepoItems[plugin_id].Author;
@@ -319,10 +363,14 @@
/// <exception cref="Capuchin.NoSuchPluginException">
/// Thrown when given plugin is not in the repository
/// </exception>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string GetPluginVersion (string plugin_id)
{
Log.Info ("Getting version of plugin {0}", plugin_id);
+ this.RepoInitialized ();
this.PluginIdExists (plugin_id);
return this.RepoItems[plugin_id].Version;
@@ -332,10 +380,15 @@
/// Get all available tags available in this repository
/// </summary>
/// <returns>A list of tags</returns>
+ /// <exception cref="Capuchin.RepositoryNotInitializedException">
+ /// Thrown when the Update method hasn't been called before
+ /// </exception>
public string[] GetTags ()
{
Log.Info ("Getting all tags in the repository");
+ this.RepoInitialized ();
+
ICollection<string> tagsCol = this.TagToPlugins.Keys;
string[] tags = new string[tagsCol.Count];
tagsCol.CopyTo (tags, 0);
@@ -436,6 +489,13 @@
}
}
+ protected void RepoInitialized ()
+ {
+ if (this.RepoItems == null) {
+ throw new RepositoryNotInitializedException ("The repository is not initialized. You have to call Update first.");
+ }
+ }
+
protected void OnUpdateFinished ()
{
if (UpdateFinished != null)
Added: trunk/src/libcapuchin/RepositoryNotInitializedException.cs
==============================================================================
--- (empty file)
+++ trunk/src/libcapuchin/RepositoryNotInitializedException.cs Wed Mar 12 17:30:13 2008
@@ -0,0 +1,13 @@
+using System;
+
+namespace Capuchin
+{
+
+ public class RepositoryNotInitializedException : ApplicationException
+ {
+ public RepositoryNotInitializedException() { }
+ public RepositoryNotInitializedException(string message) : base(message) { }
+ public RepositoryNotInitializedException(string message, Exception inner) : base(message, inner) { }
+ }
+
+}
\ No newline at end of file
Modified: trunk/src/libcapuchin/libcapuchin.mdp
==============================================================================
--- trunk/src/libcapuchin/libcapuchin.mdp (original)
+++ trunk/src/libcapuchin/libcapuchin.mdp Wed Mar 12 17:30:13 2008
@@ -51,6 +51,7 @@
<File name="Installation/Simple/SimpleInstaller.cs" subtype="Code" buildaction="Compile" />
<File name="RepositoryConnectionException.cs" subtype="Code" buildaction="Compile" />
<File name="NoSuchPluginException.cs" subtype="Code" buildaction="Compile" />
+ <File name="RepositoryNotInitializedException.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="gnome-vfs-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]