ktlili      2005/06/09 18:46:15 CEST

  Modified files:
    war/MavenWebClipping MavenWebClipping.jpx 
    war/src/java/com/jahia/clipping/Bean UrlBean.java 
    war/src/java/com/jahia/clipping/struts 
                                           DescriptionClipperAction.java 
                                           SelectPartAction.java 
    war/src/java/com/jahia/clipping/web HTMLDocumentBuilder.java 
    war/src/java/com/jahia/clipping/web/html HTMLDocument.java 
    war/src/java/com/jahia/clipping/web/html/Impl 
                                                  DefaultHTMLParser.java 
                                                  DefaultHTMLTransformer.java 
    war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser 
                                                             
HTMLParserDocument.java 
                                                             
HTMLParserTransformer.java 
    war/src/java/com/jahia/clipping/web/html/Impl/JDom 
                                                       JDomHTMLDocument.java 
    war/src/java/com/jahia/clipping/web/html/Impl/Neko 
                                                       DomHTMLDocument.java 
                                                       DomHTMLTransformer.java 
    war/src/java/com/jahia/clipping/web/http/impl 
                                                  HttpProcessor.java 
    war/src/webapp/jsp   wizard.jsp 
  Log:
  Fix several Bugs JDOMHTMLDocument
  Fix several Bugs Bug DOMHTMLDocument
  Fix several Bugs Bug HttpClient
  
  Revision  Changes    Path
  1.9       +0 -5      webclip_builder/war/MavenWebClipping/MavenWebClipping.jpx
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/MavenWebClipping/MavenWebClipping.jpx.diff?r1=1.8&r2=1.9&f=h
  1.4       +1 -0      
webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java.diff?r1=1.3&r2=1.4&f=h
  1.3       +8 -4      
webclip_builder/war/src/java/com/jahia/clipping/struts/DescriptionClipperAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/struts/DescriptionClipperAction.java.diff?r1=1.2&r2=1.3&f=h
  1.5       +6 -5      
webclip_builder/war/src/java/com/jahia/clipping/struts/SelectPartAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/struts/SelectPartAction.java.diff?r1=1.4&r2=1.5&f=h
  1.7       +6 -6      
webclip_builder/war/src/java/com/jahia/clipping/web/HTMLDocumentBuilder.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/HTMLDocumentBuilder.java.diff?r1=1.6&r2=1.7&f=h
  1.6       +0 -15     
webclip_builder/war/src/java/com/jahia/clipping/web/html/HTMLDocument.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/HTMLDocument.java.diff?r1=1.5&r2=1.6&f=h
  1.5       +11 -4     
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLParser.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLParser.java.diff?r1=1.4&r2=1.5&f=h
  1.9       +1 -8      
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLTransformer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLTransformer.java.diff?r1=1.8&r2=1.9&f=h
  1.4       +0 -44     
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/HTMLParserDocument.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/HTMLParserDocument.java.diff?r1=1.3&r2=1.4&f=h
  1.6       +1 -1      
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/HTMLParserTransformer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/HTMLParserTransformer.java.diff?r1=1.5&r2=1.6&f=h
  1.6       +0 -11     
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/JDom/JDomHTMLDocument.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/JDom/JDomHTMLDocument.java.diff?r1=1.5&r2=1.6&f=h
  1.4       +4 -26     
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLDocument.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLDocument.java.diff?r1=1.3&r2=1.4&f=h
  1.5       +153 -50   
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLTransformer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLTransformer.java.diff?r1=1.4&r2=1.5&f=h
  1.4       +10 -6     
webclip_builder/war/src/java/com/jahia/clipping/web/http/impl/HttpProcessor.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/http/impl/HttpProcessor.java.diff?r1=1.3&r2=1.4&f=h
  1.2       +0 -8      webclip_builder/war/src/webapp/jsp/wizard.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/webapp/jsp/wizard.jsp.diff?r1=1.1&r2=1.2&f=h
  
  
  
  Index: MavenWebClipping.jpx
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/MavenWebClipping/MavenWebClipping.jpx,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MavenWebClipping.jpx      8 Jun 2005 15:43:45 -0000       1.8
  +++ MavenWebClipping.jpx      9 Jun 2005 16:46:12 -0000       1.9
  @@ -31,7 +31,6 @@
     <property category="module" 
name="ProjectConvertedToUseProperModuleDefaults" value="1"/>
     <property category="module" name="last.wizard.module.name" value="webapp"/>
     <property category="module" 
name="projectConvertedFromModuleExtensionsToModuleFileTypes" value="1"/>
  -  <property category="runtime" name="ConfigurationCount" value="1"/>
     <property category="runtime" name="DefaultConfiguration" value="-1"/>
     <property category="runtime.0" name="BuildTargetOnRun" 
value="com.borland.jbuilder.build.ExternalTaskBuilder;MavenBuild"/>
     <property category="runtime.0" name="ConfigurationName" value="Tomcat 
4.1"/>
  @@ -45,10 +44,6 @@
     <property category="runtime.0" name="server.instance.name" value=""/>
     <property category="runtime.0" name="server.name" value="Tomcat 4.1"/>
     <property category="runtime.0" name="server.vmparameters" value=""/>
  -  <property category="runtime.1" name="ConfigurationName" 
value="TestStringTreeExtractorFilter"/>
  -  <property category="runtime.1" name="RunnableType" 
value="com.borland.jbuilder.runtime.TestRunner"/>
  -  <property category="runtime.1" name="test.class" 
value="com.jahia.clipping.web.html.Impl.TestStringTreeExtractorFilter"/>
  -  <property category="runtime.1" name="test.harness" 
value="com.borland.jbuilder.unittest.JBTestRunner"/>
     <property category="serverservices" name="disabled.services" 
value="jdatastore;sqlj"/>
     <property category="serverservices" name="single.server.name" 
value="Tomcat 4.1"/>
     <property category="sys" name="AuthorLabel" value="@author"/>
  
  
  
  Index: UrlBean.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UrlBean.java      7 Jun 2005 17:42:45 -0000       1.3
  +++ UrlBean.java      9 Jun 2005 16:46:12 -0000       1.4
  @@ -41,6 +41,7 @@
         */
        public UrlBean(ClipperBean cBean, URL baseURL, Map queryParamMap) {
                setURL(baseURL);
  +                setRedirectUrl(baseURL);
                setClipperBean(cBean);
                setQueryParamListFromMap(queryParamMap);
        }
  
  
  
  Index: DescriptionClipperAction.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/struts/DescriptionClipperAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DescriptionClipperAction.java     8 Mar 2005 17:29:44 -0000       1.2
  +++ DescriptionClipperAction.java     9 Jun 2005 16:46:13 -0000       1.3
  @@ -4,7 +4,7 @@
   import com.jahia.clipping.struts.Util.*;
   import javax.servlet.http.*;
   import java.util.*;
  -import java.net.*;
  +import com.jahia.clipping.Bean.ClipperBean;
   
   /**
    *  Description of the Class
  @@ -27,7 +27,7 @@
                map.put("button.next", "goToBrowse");
                map.put("description.button.reset", "reset");
                map.put("description.button.configure", "configure");
  -
  +             map.put("button.description.update", "update");
                return map;
        }
   
  @@ -108,10 +108,14 @@
         [EMAIL PROTECTED]  httpServletResponse  Description of Parameter
         [EMAIL PROTECTED]                      Description of the Returned 
Value
         */
  -     public ActionForward update(ActionMapping actionMapping, ActionForm 
actionForm, HttpServletRequest httpServletRequest,
  -                     HttpServletResponse httpServletResponse) {
  +     public ActionForward update(ActionMapping actionMapping, ActionForm 
actionForm, HttpServletRequest httpServletRequest,HttpServletResponse 
httpServletResponse) {
                logger.debug("[ updfate ]");
                DescriptionClipperForm form = (DescriptionClipperForm) 
actionForm;
  +                ClipperBean cb = getClipperBean(httpServletRequest);
  +                String name = form.getWebClippingName();
  +                String description = form.getWebClippingDescription();
  +                cb.setName(name);
  +                cb.setDescription(description);
                return actionMapping.getInputForward();
        }
   
  
  
  
  Index: SelectPartAction.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/struts/SelectPartAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SelectPartAction.java     8 Jun 2005 15:43:46 -0000       1.4
  +++ SelectPartAction.java     9 Jun 2005 16:46:13 -0000       1.5
  @@ -91,7 +91,6 @@
                logger.debug("[ Selected content is " + selectedContent + " ]");
                bean.setFilter(filter);
   
  -
                return actionMapping.findForward("preview");
        }
   
  @@ -126,7 +125,9 @@
   
                //set the selected part
                String hashSelectedPart = 
selectPartForm.getWebClippingPartHashCode();
  -             String selectedContent = 
doc.getSelectPartFromHash(hashSelectedPart);
  +             //String selectedContent = 
doc.getSelectPartFromHash(hashSelectedPart);
  +             String selectedContent = "view filter not available";
  +
                selectPartForm.setSelectedContent(selectedContent);
   
                //set the HTMLFilter
  @@ -320,12 +321,12 @@
                // set the content
                String html = doc.getTransformedDocumentAsString();
                try {
  -                     String encodedHTML = new 
String(html.getBytes(),httpServletResponse.getCharacterEncoding());
  +                     String encodedHTML = new String(html.getBytes(), 
httpServletResponse.getCharacterEncoding());
                        selectPartForm.setBodyContent(encodedHTML);
                }
                catch (UnsupportedEncodingException ex) {
  -                    ex.printStackTrace();
  -                    selectPartForm.setBodyContent(html);
  +                     ex.printStackTrace();
  +                     selectPartForm.setBodyContent(html);
                }
   
                return actionMapping.getInputForward();
  
  
  
  Index: HTMLDocumentBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/HTMLDocumentBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HTMLDocumentBuilder.java  8 Jun 2005 15:43:47 -0000       1.6
  +++ HTMLDocumentBuilder.java  9 Jun 2005 16:46:13 -0000       1.7
  @@ -133,11 +133,10 @@
                String[] res = getHtmlAsStringAndCharEncoding(request);
                String html = res[0];
   
  -
                // Execute whith the choosen parser
                logger.debug("[ Get HTML as docuement ]");
                HTMLDocument htmlDocument = buildHtmlDocument(request, 
response, html);
  -
  +               // 
logger.debug(htmlDocument.getTransformedDocumentAsString());
                return htmlDocument;
        }
   
  @@ -239,6 +238,7 @@
                                }
   
                        }
  +                     
//logger.debug(htmlDocument.getOriginalDocumentAsString());
                        return htmlDocument;
                }
                catch (WebClippingException ex) {
  @@ -397,10 +397,10 @@
        /**
         *  Description of the Method
         *
  -      [EMAIL PROTECTED]  request       Description of Parameter
  -      [EMAIL PROTECTED]  response      Description of Parameter
  -      [EMAIL PROTECTED]  html          Description of Parameter
  -      [EMAIL PROTECTED]               Description of the Returned Value
  +      [EMAIL PROTECTED]  request   Description of Parameter
  +      [EMAIL PROTECTED]  response  Description of Parameter
  +      [EMAIL PROTECTED]  html      Description of Parameter
  +      [EMAIL PROTECTED]           Description of the Returned Value
         */
        private HTMLDocument executeWhithNekoParser(HttpServletRequest request, 
HttpServletResponse response, String html) {
                // HTML --> XHTML
  
  
  
  Index: HTMLDocument.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/HTMLDocument.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HTMLDocument.java 14 Mar 2005 16:29:35 -0000      1.5
  +++ HTMLDocument.java 9 Jun 2005 16:46:13 -0000       1.6
  @@ -11,13 +11,6 @@
    */
   public interface HTMLDocument {
   
  -     /**
  -      *  Gets the W3CDocument attribute of the HTMLDocument object
  -      *
  -      [EMAIL PROTECTED]    The W3CDocument value
  -      */
  -     public org.jdom.Document getJDOMTransformedDocument();
  -
   
        /**
         *  Gets the Transformer attribute of the HTMLDocument object
  @@ -54,14 +47,6 @@
        public String getOriginalDocumentAsString();
   
   
  -     /**
  -      *  Gets the SelectPartFromHash attribute of the HTMLDocument object
  -      *
  -      [EMAIL PROTECTED]  hash  Description of Parameter
  -      [EMAIL PROTECTED]       The SelectPartFromHash value
  -      */
  -     public String getSelectPartFromHash(String hash);
  -
   
        /**
         *  Gets the TransformedDocumentAsString attribute of the HTMLDocument 
object
  
  
  
  Index: DefaultHTMLParser.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLParser.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultHTMLParser.java    14 Mar 2005 16:29:35 -0000      1.4
  +++ DefaultHTMLParser.java    9 Jun 2005 16:46:13 -0000       1.5
  @@ -33,6 +33,8 @@
         */
        public void setConfiguration(HTMLConfiguration configuration) {
                logger.debug("[ Set configutation ]");
  +
  +
                this.configuration = configuration;
        }
   
  @@ -43,6 +45,7 @@
         [EMAIL PROTECTED]    The Transformer value
         */
        public HTMLConfiguration getConfiguration() {
  +
                return configuration;
        }
   
  @@ -60,8 +63,7 @@
                Document htmlDocument = null;
                try {
                        //Parser
  -                     java.io.InputStream in = new 
java.io.StringBufferInputStream(
  -                                     html);
  +                     java.io.InputStream in = new 
java.io.StringBufferInputStream(html);
   
                        DOMParser parser = new DOMParser(configuration);
                        parser.parse(new InputSource(in));
  @@ -69,10 +71,10 @@
                        logger.debug("[ Parsing finished. ]");
                }
                catch (IOException ex) {
  -                  ex.printStackTrace();
  +                     ex.printStackTrace();
                }
                catch (SAXException ex) {
  -                  ex.printStackTrace();
  +                     ex.printStackTrace();
                }
   
                return htmlDocument;
  @@ -94,6 +96,11 @@
                
configuration.setFeature("http://cyberneko.org/html/features/scanner/script/strip-comment-delims";,
 true);
                
configuration.setFeature("http://cyberneko.org/html/features/scanner/style/strip-comment-delims";,
 true);
                
configuration.setFeature("http://apache.org/xml/features/scanner/notify-builtin-refs";,
 true);
  +                // Deal whith namespace
  +                
configuration.setFeature("http://xml.org/sax/features/namespaces";, false);
  +                
configuration.setFeature("http://cyberneko.org/html/features/insert-namespaces";,
 false);
  +                
configuration.setFeature("http://cyberneko.org/html/features/override-namespaces";,
 false);
  +
   
        }
   
  
  
  
  Index: DefaultHTMLTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLTransformer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultHTMLTransformer.java       8 Jun 2005 15:43:47 -0000       1.8
  +++ DefaultHTMLTransformer.java       9 Jun 2005 16:46:13 -0000       1.9
  @@ -143,18 +143,11 @@
         [EMAIL PROTECTED]  Exception  Description of Exception
         */
        public String getRewritedHrefValue(String href) throws Exception {
  -             //test an url.
  -             //      if (URLUtilities.isRelatif(href) || (href!=null && 
href.substring(4).equalsIgnoreCase("http"))) {
                href = 
URLUtilities.getHrefAbsoluteValue(getUrlBean().getUrlValue(), href);
                String[] params = {href};
                UrlEncoder encoder = new UrlEncoder(getHttpServletRequest(), 
getHttpServletResponse(), "browse", params);
                return encoder.getEncodedUrl();
  -             /*
  -              *  }
  -              *  else {
  -              *  return href;
  -              *  }
  -              */
  +
        }
   
   
  
  
  
  Index: HTMLParserDocument.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/HTMLParserDocument.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HTMLParserDocument.java   14 Mar 2005 16:29:35 -0000      1.3
  +++ HTMLParserDocument.java   9 Jun 2005 16:46:14 -0000       1.4
  @@ -83,40 +83,6 @@
   
   
        /**
  -      *  Gets the W3CDocument attribute of the HTMLDocument object
  -      *
  -      [EMAIL PROTECTED]    The W3CDocument value
  -      */
  -     public org.jdom.Document getJDOMTransformedDocument() {
  -
  -             org.jdom.Document jdomDoc = null;
  -             // build the transformed document
  -             try {
  -                     HTMLParser parser = new DefaultHTMLParser();
  -                     org.jdom.input.DOMBuilder builder = new 
org.jdom.input.DOMBuilder();
  -                     String html = getTransformedDocument();
  -                     if (html == null) {
  -                             logger.error("[ transformed html document is 
null ]");
  -                     }else{
  -                          logger.debug("\n"+html);
  -                        }
  -                     org.w3c.dom.Document w3cDoc = parser.parse(html);
  -                     jdomDoc = builder.build(w3cDoc);
  -             }
  -             catch (SAXException ex) {
  -                     ex.printStackTrace();
  -             }
  -             catch (IOException ex) {
  -                     ex.printStackTrace();
  -             }
  -             finally {
  -                     return jdomDoc;
  -             }
  -
  -     }
  -
  -
  -     /**
         *  Gets the ChewDocumentAsString attribute of the HTMLDocument object
         *
         [EMAIL PROTECTED]    The ChewDocumentAsString value
  @@ -152,16 +118,6 @@
        }
   
   
  -     /**
  -      *  Gets the SelectPartFromHash attribute of the HTMLDocument object
  -      *
  -      [EMAIL PROTECTED]  hash  Description of Parameter
  -      [EMAIL PROTECTED]       The SelectPartFromHash value
  -      */
  -     public String getSelectPartFromHash(String hash) {
  -             return "";
  -     }
  -
   
        /**
         *  Gets the TransformationErrors attribute of the HTMLParserDocument 
object
  
  
  
  Index: HTMLParserTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/HTMLParserTransformer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HTMLParserTransformer.java        8 Jun 2005 15:43:48 -0000       1.5
  +++ HTMLParserTransformer.java        9 Jun 2005 16:46:14 -0000       1.6
  @@ -398,7 +398,7 @@
   
                }
                catch (Exception ex) {
  -                     throw new WebClippingException("Form tag", ex);
  +                     throw new WebClippingException("Head tag", ex);
                }
                finally {
                        return tag;
  
  
  
  Index: JDomHTMLDocument.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/JDom/JDomHTMLDocument.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JDomHTMLDocument.java     8 Jun 2005 15:43:48 -0000       1.5
  +++ JDomHTMLDocument.java     9 Jun 2005 16:46:14 -0000       1.6
  @@ -200,17 +200,6 @@
                return urlBean;
        }
   
  -
  -     /**
  -      *  Gets the W3cOriginalDocument attribute of the JDomHTMLDocument 
object
  -      *
  -      [EMAIL PROTECTED]    The W3cOriginalDocument value
  -      */
  -     public org.jdom.Document getJDOMTransformedDocument() {
  -             return getTransformedDocument();
  -     }
  -
  -
        /**
         *  Gets the OriginalDocument attribute of the JDomHTMLDocument object
         *
  
  
  
  Index: DomHTMLDocument.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLDocument.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DomHTMLDocument.java      7 Mar 2005 17:44:39 -0000       1.3
  +++ DomHTMLDocument.java      9 Jun 2005 16:46:14 -0000       1.4
  @@ -12,7 +12,7 @@
    */
   public class DomHTMLDocument implements HTMLDocument {
        private UrlBean uBean;
  -     private String originalHTMLDocumentAsString;
  +     //private String originalHTMLDocumentAsString;
   
        // Documents
        private org.w3c.dom.Document w3cOriginalDocument;
  @@ -34,9 +34,7 @@
         */
        public DomHTMLDocument(UrlBean uBean, org.w3c.dom.Document document, 
String htmlDocumentAsString) {
                setW3cOriginalDocument(document);
  -             setTransformedDocument(document);
                setUrlBean(uBean);
  -             setOriginalHTMLSocumentAsString(htmlDocumentAsString);
        }
   
   
  @@ -53,17 +51,6 @@
   
   
   
  -     /**
  -      *  Sets the OriginalHTMLSocumentAsString attribute of the 
XercesHTMLDocument
  -      *  object
  -      *
  -      [EMAIL PROTECTED]  originalHTMLSocumentAsString  The new 
OriginalHTMLSocumentAsString
  -      *      value
  -      */
  -     public void setOriginalHTMLSocumentAsString(String
  -                     originalHTMLSocumentAsString) {
  -             this.originalHTMLDocumentAsString = 
originalHTMLSocumentAsString;
  -     }
   
   
        /**
  @@ -107,16 +94,6 @@
        }
   
   
  -     /**
  -      *  Gets the JDOMTransformedDocument attribute of the DomHTMLDocument 
object
  -      *
  -      [EMAIL PROTECTED]    The JDOMTransformedDocument value
  -      */
  -     public org.jdom.Document getJDOMTransformedDocument() {
  -             org.jdom.input.DOMBuilder builder = new 
org.jdom.input.DOMBuilder();
  -             org.jdom.Document jdomDoc = 
builder.build(this.getTransformedDocument());
  -             return jdomDoc;
  -     }
   
   
        /**
  @@ -146,8 +123,8 @@
         [EMAIL PROTECTED]    The OriginalHTMLSocumentAsString value
         */
        public String getOriginalDocumentAsString() {
  -             return originalHTMLDocumentAsString;
  -     }
  +            return 
DomUtilities.getDocumentAsString(getW3cOriginalDocument());
  +        }
   
   
        /**
  @@ -158,6 +135,7 @@
        public Document getTransformedDocument() {
                logger.debug("[ Get transformed document ]");
                if (transformedDocument == null) {
  +                     logger.debug("Transformed document is null, build it");
                        getTransformer().buildTransformedDocument();
                }
                return transformedDocument;
  
  
  
  Index: DomHTMLTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLTransformer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DomHTMLTransformer.java   7 Jun 2005 17:42:48 -0000       1.4
  +++ DomHTMLTransformer.java   9 Jun 2005 16:46:14 -0000       1.5
  @@ -22,35 +22,14 @@
   public class DomHTMLTransformer extends DefaultHTMLTransformer {
        private DomHTMLDocument document;
        //Xpath
  -     /**
  -      *  All link element
  -      */
  -     public static final String LINK_ELE_XPATH = "//[EMAIL PROTECTED]";
  -
  -     /**
  -      *  Description of the Field
  -      */
  -     public static final String INPUT_ELE_XPATH = "//input";
  -
  -     /**
  -      *  All action att
  -      */
  -     public static final String ACTION_ATT_XPATH = "//@action";
  -
  -     /**
  -      *  All href att
  -      */
  -     public static final String HREF_ATT_XPATH = "//@href";
  -     /**
  -      *  All src att
  -      */
  -     public static final String SRC_ATT_XPATH = "//@src";
  -
  -     /**
  -      *  Description of the Field
  -      */
  -     public static String FORM_ELE_XPATH = "//form";
  -
  +     private final String LINK_ELE_XPATH = "//[EMAIL 
PROTECTED]'stylesheet']|//[EMAIL PROTECTED]'text/css']";
  +     private final String INPUT_ELE_XPATH = "//input";
  +     private final String ACTION_ATT_XPATH = "//@action";
  +     private final String HREF_ATT_XPATH = "//@href";
  +     private final String SRC_ATT_XPATH = "//@src";
  +     private final String FORM_ELE_XPATH = "//form";
  +     private final String SYTLE_ELE_XPATH = "//style";
  +     private final String SCRIPT_ELE_XPATH = "//script";
        private static org.apache.log4j.Logger logger = 
org.apache.log4j.Logger.getLogger(DomHTMLTransformer.class);
   
   
  @@ -192,9 +171,11 @@
                        processBodyElement(transformedDocument);
   
                        //Rewrite urls
  -                     processHrefAttribute(transformedDocument);
                        processActionAttribute(transformedDocument);
                        processSrcAttribute(transformedDocument);
  +                     processSytleElement(transformedDocument);
  +                     processScriptElement(transformedDocument);
  +                     processHrefAttribute(transformedDocument);
   
                }
   
  @@ -277,6 +258,8 @@
                body = this.getBodyNode(doc);
                if (body != null) {
                        doc.renameNode(body, "", HTML.Tag.DIV.toString());
  +                     String classValue = CssUtilities.BODY_CLASS;
  +                     body.setAttribute(HTML.Attribute.CLASS.toString(), 
classValue);
                }
                else {
                        logger.error("[Body element not found]");
  @@ -341,6 +324,7 @@
                                
att.setNodeValue(relatifToAbsolute(att.getNodeValue()));
                        }
                        catch (Exception ex) {
  +                             ex.printStackTrace();
                                addParsingErrors("Src rewriting error: " + 
ex.toString());
                        }
                }
  @@ -349,6 +333,117 @@
   
   
        /**
  +      *  Description of the Method
  +      *
  +      [EMAIL PROTECTED]  doc  Description of Parameter
  +      */
  +     private void processSytleElement(Document doc) {
  +             logger.debug("[ Process StyleTag ]");
  +             NodeList eleList = DomUtilities.getNodeListByXPath(doc, 
this.SYTLE_ELE_XPATH);
  +
  +             for (int i = 0; i < eleList.getLength(); i++) {
  +                     Node ele = eleList.item(i);
  +                     NodeList children = ele.getChildNodes();
  +                     Node child = null;
  +                     //look for text node
  +                     for (int j = 0; j < children.getLength(); j++) {
  +                             child = children.item(j);
  +
  +                             // style is set as text
  +                             if (child instanceof Text) {
  +                                     logger.debug("Sytle Text found");
  +                                     Text tChild = (Text) child;
  +                                     try {
  +                                             String content = 
getInlineCssContent(child.getNodeValue());
  +                                             Comment comment = 
doc.createComment(content);
  +                                             ele.appendChild(comment);
  +                                             ele.removeChild(tChild);
  +                                             break;
  +                                     }
  +                                     catch (Exception ex) {
  +                                             ex.printStackTrace();
  +                                     }
  +                             }
  +                             else {
  +                                     // style is set as Comment
  +                                     if (child instanceof Comment) {
  +                                             logger.debug("Style set as 
comment");
  +                                             Comment cChild = (Comment) 
child;
  +                                             try {
  +                                                     String comment = 
getInlineCssContent(cChild.getNodeValue());
  +                                                     
cChild.setNodeValue(comment);
  +                                             }
  +                                             catch (Exception ex) {
  +                                                     ex.printStackTrace();
  +                                             }
  +                                     }
  +                                     else {
  +                                             logger.debug("Child is not a 
Text, it's a: " + child.toString());
  +                                     }
  +                             }
  +
  +                     }
  +
  +             }
  +
  +     }
  +
  +
  +     /**
  +      *  Description of the Method
  +      *
  +      [EMAIL PROTECTED]  doc  Description of Parameter
  +      */
  +     private void processScriptElement(Document doc) {
  +             logger.debug("[ Process StyleTag ]");
  +             NodeList eleList = DomUtilities.getNodeListByXPath(doc, 
SCRIPT_ELE_XPATH);
  +             for (int i = 0; i < eleList.getLength(); i++) {
  +                     Element ele = (Element) eleList.item(i);
  +                     NodeList children = ele.getChildNodes();
  +                     Node child = null;
  +                     //Inline script
  +                     for (int j = 0; j < children.getLength(); j++) {
  +                             child = children.item(j);
  +                             // style is set as text
  +                             if (child instanceof Text) {
  +                                     logger.debug("script Text found");
  +                                     Text tChild = (Text) child;
  +                                     try {
  +                                             Comment comment = 
doc.createComment(child.getNodeValue());
  +                                             ele.appendChild(comment);
  +                                             ele.removeChild(tChild);
  +                                             break;
  +                                     }
  +                                     catch (Exception ex) {
  +                                             ex.printStackTrace();
  +                                     }
  +                             }
  +                     }
  +
  +                     //imported Script
  +                     String src = 
ele.getAttribute(HTML.Attribute.SRC.toString());
  +                     if (src != null && !src.equals("")) {
  +                             // get content
  +                             try {
  +                                     String content = 
getImportJavascriptContent(src);
  +                                     // add it as comment
  +                                     Comment comment = 
doc.createComment(content);
  +                                     
ele.removeAttribute(HTML.Attribute.SRC.toString());
  +                                     ele.appendChild(comment);
  +                             }
  +                             catch (Exception ex) {
  +                                     ex.printStackTrace();
  +                                     addParsingErrors("Extraction 
Javascript: " + ex.toString());
  +                             }
  +                     }
  +
  +             }
  +
  +     }
  +
  +
  +
  +     /**
         *  Extract css from link element and make it icluded css
         *
         [EMAIL PROTECTED]  doc  Description of Parameter
  @@ -362,15 +457,18 @@
                                Element ele = (Element) elements.item(i);
                                if (isEnableCSS()) {
                                        // create a style element
  -                                     Element style = 
doc.createElement(HTML.Tag.STYLE.toString());
  +                                     Element style = 
ele.getOwnerDocument().createElement(HTML.Tag.STYLE.toString());
                                        String href = 
ele.getAttribute(HTML.Attribute.HREF.toString());
  -                                        String media = 
ele.getAttribute("media");
  -                                     String content = 
getImportCssContent(href,media);
  -                                     Comment comment = 
doc.createComment(content);
  -
  +                                     String media = 
ele.getAttribute("media");
  +                                     String content = 
getImportCssContent(href, media);
  +                                     Comment comment = 
ele.getOwnerDocument().createComment(content);
                                        //replace link by a style ehich contain 
the css
                                        style.appendChild(comment);
  -                                     doc.replaceChild(ele, style);
  +                                     ele.appendChild(style);
  +
  +                                     
//ele.getOwnerDocument().replaceChild(ele, style);
  +                                     // 
ele.getOwnerDocument().appendChild(style);
  +
                                }
                                else {
                                        // remove link tag
  @@ -379,9 +477,11 @@
                                }
                        }
                        catch (Exception ex) {
  +                             ex.printStackTrace();
                                addParsingErrors("CSS Parsing error: " + 
ex.toString());
                        }
                }
  +
        }
   
   
  @@ -426,17 +526,18 @@
        /**
         *  Description of the Method
         *
  -      [EMAIL PROTECTED]  transformedDocument  Description of Parameter
  -      [EMAIL PROTECTED]  DOMException     Description of Exception
  +      [EMAIL PROTECTED]  doc               Description of Parameter
  +      [EMAIL PROTECTED]  DOMException  Description of Exception
         */
  -     private void processTitleElement(Document transformedDocument) throws 
DOMException {
  +     private void processTitleElement(DocumentImpl doc) throws DOMException {
                //remove title
  -             Element title = (Element) 
transformedDocument.getElementsByTagName(HTML.Tag.TITLE.toString()).item(0);
  +             Element title = (Element) 
doc.getElementsByTagName(HTML.Tag.TITLE.toString()).item(0);
                if (title != null) {
                        DomUtilities.removeNode(title);
  +                     //doc.renameNode(doc, "", HTML.Tag.DIV.toString());
                }
                else {
  -                     addParsingErrors("Title element no found");
  +                     //addParsingErrors("Title element no found");
                }
        }
   
  @@ -444,19 +545,21 @@
        /**
         *  Description of the Method
         *
  -      [EMAIL PROTECTED]  doc               Description of Parameter
  +      [EMAIL PROTECTED]  doc  Description of Parameter
         */
        private void processHtmlElement(DocumentImpl doc) {
                //change tag HTML-->div
                Element html = (Element) 
doc.getElementsByTagName(HTML.Tag.HTML.toString()).item(0);
                doc.renameNode(html, "", HTML.Tag.DIV.toString());
  +             String classValue = CssUtilities.HTML_CLASS;
  +             html.setAttribute(HTML.Attribute.CLASS.toString(), classValue);
        }
   
   
        /**
         *  Process Form element
         *
  -      [EMAIL PROTECTED]  doc            Description of Parameter
  +      [EMAIL PROTECTED]  doc  Description of Parameter
         */
        private void processFormElement(Document doc) {
                // add action input elements params
  @@ -523,15 +626,15 @@
        /**
         *  Description of the Method
         *
  -      [EMAIL PROTECTED]  transformedDocument  Description of Parameter
  -      [EMAIL PROTECTED]  DOMException     Description of Exception
  +      [EMAIL PROTECTED]  doc  Description of Parameter
         */
  -     private void processHeadElement(Document transformedDocument) {
  +     private void processHeadElement(DocumentImpl doc) {
                //remove head
  -             Element head = (Element) getHeadNode(transformedDocument);
  +             Element head = (Element) getHeadNode(doc);
                if (head != null) {
  -                     Node parent = head.getParentNode();
  -                     parent.removeChild(head);
  +                     //Node parent = head.getParentNode();
  +                     doc.renameNode(head, "", HTML.Tag.DIV.toString());
  +                     //parent.removeChild(head);
                }
        }
   
  @@ -571,7 +674,7 @@
                //add text to <i>
                Text text = originalDoc.createTextNode("[Param=" + name + "]");
                if (type != null && 
type.equalsIgnoreCase(WebConstants.TYPE_RADIO)) {
  -                     text = originalDoc.createTextNode("[Param=" + name + ", 
value=\'" + value +"\']");
  +                     text = originalDoc.createTextNode("[Param=" + name + ", 
value=\'" + value + "\']");
                }
                labelEle.appendChild(text);
                return labelEle;
  
  
  
  Index: HttpProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/http/impl/HttpProcessor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpProcessor.java        8 Jun 2005 15:43:48 -0000       1.3
  +++ HttpProcessor.java        9 Jun 2005 16:46:15 -0000       1.4
  @@ -100,11 +100,15 @@
                // Create a method instance.
                logger.debug("[ Method is " + httpMethod + "]");
                if (httpMethod.equalsIgnoreCase("GET")) {
  -                     setObjectMethod(new GetMethod());
  +                     GetMethod method = new GetMethod();
  +                        method.addRequestHeader("User-Agent","Mozilla/5.0 
(Macintosh; U; PPC MacOS X; en)");
  +                     setObjectMethod(method);
   
                }
                else if (httpMethod.equalsIgnoreCase("POST")) {
  -                     setObjectMethod(new PostMethod());
  +                     PostMethod method = new PostMethod();
  +                        method.addRequestHeader("User-Agent","Mozilla/5.0 
(Macintosh; U; PPC MacOS X; en)");
  +                     setObjectMethod(method);
                        ((PostMethod) 
getObjectMethod()).addParameters(getParamAndValue());
                }
   
  @@ -284,6 +288,7 @@
        public HttpClient getDefaultClient() {
                if (defaultClient == null) {
                        defaultClient = getNewHttpClient();
  +
                }
                return defaultClient;
        }
  @@ -541,7 +546,9 @@
   
                //HttpState
                HttpState s = getDefaultClient().getState();
  +
                Cookie[] cookiess = s.getCookies();
  +
                logger.debug("[ Begin Enumerate cookies before execution ]");
                for (int i = 0; i < cookiess.length; i++) {
                        Cookie c = cookiess[i];
  @@ -550,9 +557,7 @@
   
                // Init
                String html = null;
  -                String encoding = null;
                HTMLDocument htmlDocument = null;
  -
                try {
   
                        // Execute the method.
  @@ -605,12 +610,10 @@
                        }
                        else {
                                html = method.getResponseBodyAsString();
  -                             encoding = 
method.getResponseHeader("encoding").getValue();
                        }
   
                        // set html
                        setHtmlAsString(html);
  -                        setCharEncoding(encoding);
   
                }
                catch (HttpException e) {
  @@ -626,6 +629,7 @@
                catch (Exception e) {
                        logger.error("Fatal Exception error: " + 
e.getMessage());
                        errorHasOccured = true;
  +                     e.printStackTrace();
                        throw new WebClippingException("Fatal Exception error", 
e);
                }
   
  
  
  
  Index: wizard.jsp
  ===================================================================
  RCS file: /home/cvs/repository/webclip_builder/war/src/webapp/jsp/wizard.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- wizard.jsp        3 Mar 2005 18:04:10 -0000       1.1
  +++ wizard.jsp        9 Jun 2005 16:46:15 -0000       1.2
  @@ -16,14 +16,6 @@
           <!-- Show only the step that has been performed -->
           <tr>
             <!-- Manage -->
  -          <logic:present name="manageClippersForm">
  -            <td>
  -              <html:form action="manageAction" method="post">
  -                <html:image styleClass="wizard" pageKey="image.manage"/>
  -                <html:hidden property="webClippingAction" value="wizard"/>
  -              </html:form>
  -            </td>
  -          </logic:present>
             <!-- description -->
             <logic:present name="descriptionClipperForm">
               <td>
  

Reply via email to