public GadgetSpec getGadgetSpec(URI gadgetUri, bool ignoreCache)
        {
            Uri uri = Uri.fromJavaUri(gadgetUri);

            if (ignoreCache)
            {
                return(FetchObjectAndCache(uri, ignoreCache));
            }

            GadgetSpec cached = HttpRuntime.Cache[gadgetUri.ToString()] as GadgetSpec;

            GadgetSpec spec;

            if (cached == null)
            {
                try
                {
                    spec = FetchObjectAndCache(uri, ignoreCache);
                }
                catch (GadgetException e)
                {
                    // We create this dummy spec to avoid the cost of re-parsing when a remote site is out.
                    spec = new GadgetSpec(uri, ERROR_SPEC);
                    spec.setAttribute(ERROR_KEY, e);
                    HttpRuntime.Cache.Insert(uri.ToString(), spec, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(ERROR_DELAY));
                }
            }
            else
            {
                spec = cached;
            }

            GadgetException exception = (GadgetException)spec.getAttribute(ERROR_KEY);

            if (exception != null)
            {
                throw exception;
            }
            return(spec);
        }
Exemple #2
0
 public GadgetException(GadgetException.Code code)
 {
     this.code = code;
 }
Exemple #3
0
 public GadgetException(GadgetException.Code code, String msg, Exception cause)
     : base(msg, cause)
 {
     this.code = code;
 }
Exemple #4
0
 public GadgetException(GadgetException.Code code, String msg)
     : base(msg)
 {
     this.code = code;
 }
Exemple #5
0
 public GadgetException(GadgetException.Code code, Exception cause)
     : base(cause.Message, cause)
 {
     this.code = code;
 }