Esempio n. 1
0
        public RewriterResults rewrite(Gadget gadget, MutableContent content)
        {
            if (gadget.getSpec().getModulePrefs().getFeatures().ContainsKey("caja") ||
                "1".Equals(gadget.getContext().getParameter("caja")))
            {
                URI          retrievedUri = gadget.getContext().getUrl();
                UriCallback2 cb           = new UriCallback2(retrievedUri);

                MessageQueue          mq    = new SimpleMessageQueue();
                DefaultGadgetRewriter rw    = new DefaultGadgetRewriter(mq);
                CharProducer          input = CharProducer.Factory.create(
                    new java.io.StringReader(content.getContent()),
                    FilePosition.instance(new InputSource(new java.net.URI(retrievedUri.ToString())), 2, 1, 1));
                java.lang.StringBuilder output = new java.lang.StringBuilder();

                try
                {
                    rw.rewriteContent(new java.net.URI(retrievedUri.ToString()), input, cb, output);
                }
                catch (GadgetRewriteException e)
                {
                    throwCajolingException(e, mq);
                    return(RewriterResults.notCacheable());
                }
                catch (IOException e)
                {
                    throwCajolingException(e, mq);
                    return(RewriterResults.notCacheable());
                }
                content.setContent(tameCajaClientApi() + output.ToString());
            }
            return(null);
        }
Esempio n. 2
0
        public virtual RewriterResults rewrite(sRequest request, sResponse original, MutableContent content)
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream((content.getContent().Length * 110) / 100);
            OutputStreamWriter output = new OutputStreamWriter(baos);
            String mimeType = original.getHeader("Content-Type");
            if (request.RewriteMimeType != null)
            {
                mimeType = request.RewriteMimeType;
            }
            GadgetSpec spec = null;
            if (request.Gadget != null)
            {
                spec = _specFactory.getGadgetSpec(request.Gadget.toJavaUri(), false);
            }
            if (rewrite(spec, request.getUri(),
                        content,
                        mimeType,
                        output))
            {
                content.setContent(Encoding.Default.GetString(baos.toByteArray()));
                return RewriterResults.cacheableIndefinitely();

            }

            return null;
        }
        public virtual RewriterResults rewrite(sRequest request, sResponse original, MutableContent content)
        {
            ByteArrayOutputStream baos   = new ByteArrayOutputStream((content.getContent().Length * 110) / 100);
            OutputStreamWriter    output = new OutputStreamWriter(baos);
            String mimeType = original.getHeader("Content-Type");

            if (request.RewriteMimeType != null)
            {
                mimeType = request.RewriteMimeType;
            }
            GadgetSpec spec = null;

            if (request.Gadget != null)
            {
                spec = _specFactory.getGadgetSpec(request.Gadget.toJavaUri(), false);
            }
            if (rewrite(spec, request.getUri(),
                        content,
                        mimeType,
                        output))
            {
                content.setContent(Encoding.Default.GetString(baos.toByteArray()));
                return(RewriterResults.cacheableIndefinitely());
            }

            return(null);
        }
        public virtual RewriterResults rewrite(Gadget gadget, MutableContent content)
        {
            java.io.StringWriter sw   = new java.io.StringWriter();
            GadgetSpec           spec = gadget.getSpec();
            Uri  _base = spec.getUrl();
            View view  = gadget.getCurrentView();

            if (view != null && view.getHref() != null)
            {
                _base = view.getHref();
            }
            if (rewrite(spec, _base, content, "text/html", sw))
            {
                content.setContent(sw.toString());
            }
            return(null);
        }
Esempio n. 5
0
        public RewriterResults rewrite(Gadget gadget, MutableContent content)
        {
            if (gadget.getSpec().getModulePrefs().getFeatures().ContainsKey("caja") ||
                "1".Equals(gadget.getContext().getParameter("caja"))) 
            {
                URI retrievedUri = gadget.getContext().getUrl();
                UriCallback2 cb = new UriCallback2(retrievedUri);

                MessageQueue mq = new SimpleMessageQueue();
                DefaultGadgetRewriter rw = new DefaultGadgetRewriter(mq);
                CharProducer input = CharProducer.Factory.create(
                    new java.io.StringReader(content.getContent()),
                    FilePosition.instance(new InputSource(new java.net.URI(retrievedUri.ToString())), 2, 1, 1));
                java.lang.StringBuilder output = new java.lang.StringBuilder();

                try 
                {
                    rw.rewriteContent(new java.net.URI(retrievedUri.ToString()), input, cb, output);
                }
                catch (GadgetRewriteException e)
                {
                    throwCajolingException(e, mq);
                    return RewriterResults.notCacheable();
                }
                catch (IOException e) 
                {
                    throwCajolingException(e, mq);
                    return RewriterResults.notCacheable();
                }
                content.setContent(tameCajaClientApi() + output.ToString());

            }
            return null;
        }
Esempio n. 6
0
 public virtual RewriterResults rewrite(Gadget gadget, MutableContent content)
 {
     java.io.StringWriter sw = new java.io.StringWriter();
     GadgetSpec spec = gadget.getSpec();
     Uri _base = spec.getUrl();
     View view = gadget.getCurrentView();
     if (view != null && view.getHref() != null) 
     {
         _base = view.getHref();
     }
     if (rewrite(spec, _base, content, "text/html", sw)) 
     {
         content.setContent(sw.toString());
     }
     return null;
 }