ktlili 2005/06/24 15:37:42 CEST
Modified files:
war/src/java/com/jahia/clipping/Bean UrlBean.java
war/src/java/com/jahia/clipping/XML ClipperParser.java
ElementBuilder.java
Label.java
war/src/java/com/jahia/clipping/struts/Util
AbstractWizardAction.java
war/src/java/com/jahia/clipping/struts WebBrowserAction.java
war/src/java/com/jahia/clipping/util JavascriptUtilities.java
war/src/java/com/jahia/clipping/web WebBrowserSimulator.java
war/src/java/com/jahia/clipping/web/html/Impl
ChewExtractorFilter.java
DefaultHTMLTransformer.java
war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser
HTMLParserTransformer.java
UserBuilderVisitor.java
war/src/java/com/jahia/clipping/web/html/Impl/Neko
DomHTMLTransformer.java
war/src/java/com/jahia/clipping/web/http/impl
HttpProcessor.java
war/src/webapp/jsp/actions editAction.jsp
testClipperAction.jsp
Log:
- fix meta redirect bug
- fix visibility property filter property
- merge the 2 methods of simulating a user
Revision Changes Path
1.7 +1 -2
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.6&r2=1.7&f=h
1.6 +4 -1
webclip_builder/war/src/java/com/jahia/clipping/XML/ClipperParser.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/XML/ClipperParser.java.diff?r1=1.5&r2=1.6&f=h
1.7 +10 -6
webclip_builder/war/src/java/com/jahia/clipping/XML/ElementBuilder.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/XML/ElementBuilder.java.diff?r1=1.6&r2=1.7&f=h
1.6 +2 -1
webclip_builder/war/src/java/com/jahia/clipping/XML/Label.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/XML/Label.java.diff?r1=1.5&r2=1.6&f=h
1.6 +0 -19
webclip_builder/war/src/java/com/jahia/clipping/struts/Util/AbstractWizardAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/struts/Util/AbstractWizardAction.java.diff?r1=1.5&r2=1.6&f=h
1.2 +32 -19
webclip_builder/war/src/java/com/jahia/clipping/struts/WebBrowserAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/struts/WebBrowserAction.java.diff?r1=1.1&r2=1.2&f=h
1.3 +2 -2
webclip_builder/war/src/java/com/jahia/clipping/util/JavascriptUtilities.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/util/JavascriptUtilities.java.diff?r1=1.2&r2=1.3&f=h
1.3 +160 -92
webclip_builder/war/src/java/com/jahia/clipping/web/WebBrowserSimulator.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/WebBrowserSimulator.java.diff?r1=1.2&r2=1.3&f=h
1.5 +1 -1
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/ChewExtractorFilter.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/ChewExtractorFilter.java.diff?r1=1.4&r2=1.5&f=h
1.13 +1 -1
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.12&r2=1.13&f=h
1.10 +1 -0
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.9&r2=1.10&f=h
1.2 +2 -2
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/UserBuilderVisitor.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/UserBuilderVisitor.java.diff?r1=1.1&r2=1.2&f=h
1.8 +37 -2
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.7&r2=1.8&f=h
1.7 +6 -28
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.6&r2=1.7&f=h
1.6 +14 -16 webclip_builder/war/src/webapp/jsp/actions/editAction.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/webapp/jsp/actions/editAction.jsp.diff?r1=1.5&r2=1.6&f=h
1.6 +1 -1
webclip_builder/war/src/webapp/jsp/actions/testClipperAction.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/webapp/jsp/actions/testClipperAction.jsp.diff?r1=1.5&r2=1.6&f=h
Index: UrlBean.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- UrlBean.java 23 Jun 2005 16:15:45 -0000 1.6
+++ UrlBean.java 24 Jun 2005 13:37:39 -0000 1.7
@@ -6,8 +6,7 @@
import com.jahia.clipping.util.*;
import com.jahia.clipping.web.html.*;
import com.jahia.clipping.web.Constant.WebConstants;
-import com.jahia.clipping.web.Url.URLMap;
-import com.jahia.clipping.web.Url.URLWrapper;
+
/**
* Bean represent an Url
Index: ClipperParser.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/XML/ClipperParser.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClipperParser.java 23 Jun 2005 16:15:46 -0000 1.5
+++ ClipperParser.java 24 Jun 2005 13:37:39 -0000 1.6
@@ -2,6 +2,7 @@
import org.jdom.*;
import java.util.*;
+import com.jahia.clipping.util.DESUtilities;
/**
* Description of the Class
@@ -402,7 +403,9 @@
*/
public String getQueryDefault(int posUrl, int posParam) {
Element queryEle = getQueryParam(posUrl, posParam);
- return queryEle.getAttributeValue(Label.PARAMETER_DEFAULT);
+ String encrypted =
queryEle.getAttributeValue(Label.PARAMETER_DEFAULT);
+ String defaultValue =
DESUtilities.getInstance().encrypt(Label.KEY_ENCRYPT, encrypted);
+ return defaultValue;
}
Index: ElementBuilder.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/XML/ElementBuilder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElementBuilder.java 23 Jun 2005 16:15:46 -0000 1.6
+++ ElementBuilder.java 24 Jun 2005 13:37:39 -0000 1.7
@@ -2,7 +2,7 @@
import org.jdom.*;
import java.util.*;
-import com.jahia.clipping.web.html.Impl.*;
+import com.jahia.clipping.web.Constant.*;
import com.jahia.clipping.util.*;
/**
@@ -155,6 +155,7 @@
* Description of the Method
*
[EMAIL PROTECTED] formParentName Description of Parameter
+ [EMAIL PROTECTED] formParentId Description of Parameter
[EMAIL PROTECTED] name Description of Parameter
[EMAIL PROTECTED] mapping Description of Parameter
[EMAIL PROTECTED] type Description of Parameter
@@ -162,17 +163,19 @@
[EMAIL PROTECTED] visibility Description of Parameter
[EMAIL PROTECTED] Description of the Returned Value
*/
- public Element buildUserParam(String formParentName,String
formParentId, String name, String mapping, String type,
+ public Element buildUserParam(String formParentName, String
formParentId, String name, String mapping, String type,
ArrayList possibleValues, String visibility) {
//form-param
Element ele = new Element(Label.PARAMETER);
//form-param_attributes
ele.setAttribute(Label.PARAMETER_NAME, name);
ele.setAttribute(Label.PARAMETER_MAPPING, mapping);
- ele.setAttribute(Label.PARAMETER_TYPE, type);
+ if (type.equalsIgnoreCase(WebConstants.TYPE_PASSWORD)) {
+ ele.setAttribute(Label.PARAMETER_TYPE, type);
+ }
ele.setAttribute(Label.PARAMETER_VISIBILITY, visibility);
- ele.setAttribute(Label.FORM_PARENT_NAME, formParentName);
- ele.setAttribute(Label.FORM_PARENT_ID, formParentId);
+ ele.setAttribute(Label.FORM_PARENT_NAME, formParentName);
+ ele.setAttribute(Label.FORM_PARENT_ID, formParentId);
//possible values
for (int i = 0; i < possibleValues.size(); i++) {
@@ -197,7 +200,8 @@
Element ele = new Element(Label.PARAMETER);
//query-param_attributes
ele.setAttribute(Label.PARAMETER_NAME, name);
- ele.setAttribute(Label.PARAMETER_DEFAULT, defaultValue);
+ String encrypted =
DESUtilities.getInstance().encrypt(Label.KEY_ENCRYPT, defaultValue);
+ ele.setAttribute(Label.PARAMETER_DEFAULT, encrypted);
return ele;
}
Index: Label.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/XML/Label.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Label.java 23 Jun 2005 16:15:46 -0000 1.5
+++ Label.java 24 Jun 2005 13:37:39 -0000 1.6
@@ -8,6 +8,7 @@
[EMAIL PROTECTED] Tlili Khaled
*/
public class Label {
+ public static String KEY_ENCRYPT = "qayxsw";
public static String CLIPPER = "Clipper";
public static String SEQUENCEURL = "sequenceUrl";
public static String DESCRIPTION = "description";
@@ -32,7 +33,7 @@
public static String PARAMETER_MAPPING = "mapping";
public static String FORM_PARENT_NAME = "form-parent-name";
public static String FORM_PARENT_ID = "form-parent-id";
- public static String PARAMETER_DEFAULT = "default";
+ public static String PARAMETER_DEFAULT = "encrypted-used-value";
public static String PARAMETER_VISIBILITY = "visibility";
public static String PARAMETER_VALUE = "Possible-value";
public static String PARAMETER_TYPE = "type";
Index: AbstractWizardAction.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/struts/Util/AbstractWizardAction.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractWizardAction.java 23 Jun 2005 16:15:47 -0000 1.5
+++ AbstractWizardAction.java 24 Jun 2005 13:37:39 -0000 1.6
@@ -478,26 +478,7 @@
}
- /**
- * Sets the LastValidUrl attribute of the AbstractWizardAction object
- *
- [EMAIL PROTECTED] request The new LastValidUrl value
- */
- private void setLastValidUrl(HttpServletRequest request) {
- String lastUrl = request.getRequestURL().toString();
-
request.getSession().setAttribute(com.jahia.clipping.web.Constant.WebConstants.LAST_URL,
lastUrl);
- }
-
- /**
- * Gets the LastValidUrl attribute of the AbstractWizardAction object
- *
- [EMAIL PROTECTED] request Description of Parameter
- [EMAIL PROTECTED] The LastValidUrl value
- */
- private String getLastValidUrl(HttpServletRequest request) {
- return (String)
request.getSession().getAttribute(com.jahia.clipping.web.Constant.WebConstants.LAST_URL);
- }
Index: WebBrowserAction.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/struts/WebBrowserAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebBrowserAction.java 23 Jun 2005 16:15:46 -0000 1.1
+++ WebBrowserAction.java 24 Jun 2005 13:37:40 -0000 1.2
@@ -385,27 +385,40 @@
}
//get the selected part
- //String html = wbs.getHTMLPart();
+ //html = wbs.getHTMLPart();
+ html = wbs.getFinalHtmlResponse();
- int urlPosition = wbs.getUrlPosition();
- if (urlPosition <= bean.getPositionLastRecordeUrl()) {
- if (urlPosition == bean.getPositionLastRecordeUrl()) {
- logger.debug("Apply filter");
- html = wbs.getHTMLPart();
- // remove the simulator
- removeWebBrowserSimulator(httpServletRequest);
- }
- else {
- html = wbs.getFinalHtmlResponse();
- setWebBrowserSimulator(httpServletRequest, wbs);
- }
- }
- else {
- UrlBean uBean =
buildUrlBeanWhithDoument(httpServletRequest, httpServletResponse, form);
- HTMLDocument doc = uBean.getDocument();
- html = doc.getUserDocumentAsString();
+ //prepare the browsing step
+ logger.debug("[Init RecordingBean]");
- }
+ if (wbs.getUrlPosition() ==
getClipperBean(httpServletRequest).getPositionLastRecordeUrl()) {
+ RecordingBean rc = new
RecordingBean(RecordingBean.STOP);
+ form.setFrom(Constants.WEB_BROWSER_SHOW_BROWSE);
+ logger.debug("[Set Session Attributes]");
+ HttpSession session = httpServletRequest.getSession();
+
session.setAttribute(com.jahia.clipping.web.Constant.WebConstants.RECORDING,
rc);
+ }
+
+ /*
+ * int urlPosition = wbs.getUrlPosition();
+ * if (urlPosition <= bean.getPositionLastRecordeUrl()) {
+ * if (urlPosition == bean.getPositionLastRecordeUrl()) {
+ * logger.debug("Apply filter");
+ * html = wbs.getHTMLPart();
+ * // remove the simulator
+ * removeWebBrowserSimulator(httpServletRequest);
+ * }
+ * else {
+ * html = wbs.getFinalHtmlResponse();
+ * setWebBrowserSimulator(httpServletRequest, wbs);
+ * }
+ * }
+ * else {
+ * UrlBean uBean =
buildUrlBeanWhithDoument(httpServletRequest, httpServletResponse, form);
+ * HTMLDocument doc = uBean.getDocument();
+ * html = doc.getUserDocumentAsString();
+ * }
+ */
return html;
}
Index: JavascriptUtilities.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/util/JavascriptUtilities.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JavascriptUtilities.java 23 Jun 2005 16:15:47 -0000 1.2
+++ JavascriptUtilities.java 24 Jun 2005 13:37:40 -0000 1.3
@@ -86,8 +86,8 @@
}
}
- return originalJavascript;
- //return workString;
+ //return originalJavascript;
+ return workString;
}
Index: WebBrowserSimulator.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/WebBrowserSimulator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebBrowserSimulator.java 23 Jun 2005 16:15:48 -0000 1.2
+++ WebBrowserSimulator.java 24 Jun 2005 13:37:40 -0000 1.3
@@ -8,6 +8,11 @@
import com.jahia.clipping.web.Url.URLWrapper;
import com.jahia.clipping.web.Url.URLMap;
import com.jahia.clipping.struts.Util.Constants;
+import com.jahia.clipping.web.Constant.WebConstants;
+import com.jahia.clipping.util.HashUtilities;
+import org.htmlparser.*;
+import org.htmlparser.tags.*;
+import org.htmlparser.util.*;
/**
* Description of the Class
@@ -193,13 +198,19 @@
String html = "not Found";
try {
logger.debug("[ Get HTML Reponse ]");
+ if (false) {
+ setFinalDocument(executeWhithJavascript());
+ //html =
getFinalDocument().getTransformedDocumentAsString();
+ html =
getFinalDocument().getUserDocumentAsString();
- //if (getFinalDocument() == null) {
- setFinalDocument(execute());
- //}
- //html =
getFinalDocument().getTransformedDocumentAsString();
- html = getFinalDocument().getUserDocumentAsString();
+ // the simulation is on the client side
+ html = simulateUserInteraction(html,
getFinalDocument().getUrlBean());
+ }
+ else {
+ setFinalDocument(execute());
+ html =
getFinalDocument().getUserDocumentAsString();
+ }
}
catch (NumberFormatException ex) {
ex.printStackTrace();
@@ -258,75 +269,30 @@
/**
- * Gets the ClipperBean attribute of the WebBrowserSimulator object
- *
- [EMAIL PROTECTED] request Description of Parameter
- [EMAIL PROTECTED] The ClipperBean value
- */
- private ClipperBean getClipperBean(HttpServletRequest request) {
- return (ClipperBean)
request.getSession().getAttribute(Constants.CLIPPER_BEAN_TEMPLATE);
- }
-
-
- /**
- * Gets the RequestedDocument attribute of the WebBrowserSimulator
object
+ * Description of the Method
*
- [EMAIL PROTECTED] request Description of Parameter
- [EMAIL PROTECTED] response Description of Parameter
- [EMAIL PROTECTED] uBean Description of Parameter
- [EMAIL PROTECTED] httpMethod Description of Parameter
- [EMAIL PROTECTED] The RequestedDocument value
+ [EMAIL PROTECTED] Description of the Returned Value
[EMAIL PROTECTED] Exception Description of Exception
*/
- private HTMLDocument getRequestedDocument(HttpServletRequest request,
HttpServletResponse response, UrlBean uBean, String httpMethod) throws
Exception {
-
- // Get a HMTLDocument builder
- HTMLDocumentBuilder builder = new HTMLDocumentBuilder(uBean,
httpMethod);
-
- //Get the configuration object
- ConfigureBean configBean =
getClipperBean(request).getConfigurationBean();
-
- //configure ssl
- String ssl = configBean.getEnableSSL();
- if (ssl == null) {
-
com.jahia.clipping.web.RegisterSSLProctocol.unregisterSSLProtocol();
- }
- else {
-
com.jahia.clipping.web.RegisterSSLProctocol.registerSSLProtocol();
- }
-
- // get the type of the client and the parser
- int clientType = Integer.parseInt(configBean.getClient());
- int parserType = Integer.parseInt(configBean.getHtmlDocument());
-
- // set the javascript
- String javascript = configBean.getEnableJavascript();
- boolean javascriptBool = true;
- if (javascript == null) {
- javascriptBool = false;
- }
+ public HTMLDocument execute() throws Exception {
+ //Get all the url
+ ClipperBean cBean = getClipperBean();
+ List urlListBean = cBean.getUrlListBean();
+ HTMLDocument doc = null;
- //set Css
- String css = configBean.getEnableCSS();
- boolean cssBool = true;
- if (css == null) {
- cssBool = false;
+ // for each url, rebuild the document whithe the new value of
the parameter
+ for (int i = 0; i < urlListBean.size(); i++) {
+ UrlBean uBean = (UrlBean) urlListBean.get(i);
+ // get the url bean
+ logger.debug("[WebBrowserSimulator] Current url: " +
uBean.getUrlValue());
+
+ //update the url bean
+ doc = updateUrlBeanAndGetDoument(getRequest(),
getResponse(), uBean);
+ uBean.setDocument(doc);
+ urlPosition = i;
}
- //set headers
- org.apache.commons.httpclient.Header[] headers = new
org.apache.commons.httpclient.Header[1];
- headers = null;
- String encodingValue = response.getCharacterEncoding();
-
- logger.debug("[ Encoding is " + encodingValue + " ]");
- //headers[0] = new
org.apache.commons.httpclient.Header("Content-Type", "text/html;
charset="+encodingValue);
-
- //configure the builder
- builder.configure(clientType, parserType, javascriptBool,
cssBool, headers);
-
- // execute
- HTMLDocument doc = builder.execute(request, response);
-
+ // set the body content
return doc;
}
@@ -337,32 +303,134 @@
[EMAIL PROTECTED] Description of the Returned Value
[EMAIL PROTECTED] Exception Description of Exception
*/
- private HTMLDocument execute() throws Exception {
+ public HTMLDocument executeWhithJavascript() throws Exception {
//Get all the url
ClipperBean cBean = getClipperBean();
List urlListBean = cBean.getUrlListBean();
HTMLDocument doc = null;
-
+ UrlBean uBean = (UrlBean) urlListBean.get(urlPosition);
// for each url, rebuild the document whithe the new value of
the parameter
- //for (int i = 0; i < urlListBean.size(); i++) {
-
// get the url bean
- UrlBean uBean = (UrlBean) urlListBean.get(urlPosition);
-
logger.debug("[WebBrowserSimulator] Current url: " +
uBean.getUrlValue());
//update the url bean
doc = updateUrlBeanAndGetDoument(getRequest(), getResponse(),
uBean);
-
uBean.setDocument(doc);
urlPosition++;
- //}
// set the body content
return doc;
}
+
+ /**
+ * Gets the ClipperBean attribute of the WebBrowserSimulator object
+ *
+ [EMAIL PROTECTED] request Description of Parameter
+ [EMAIL PROTECTED] The ClipperBean value
+ */
+ private ClipperBean getClipperBean(HttpServletRequest request) {
+ return (ClipperBean)
request.getSession().getAttribute(Constants.CLIPPER_BEAN_TEMPLATE);
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] html Description of Parameter
+ [EMAIL PROTECTED] uBean Description of Parameter
+ [EMAIL PROTECTED] Description of the Returned Value
+ */
+ private String simulateUserInteraction(String html, UrlBean uBean) {
+ logger.debug(" body tag found");
+ ClipperBean cBean = uBean.getClipperBean();
+ UrlBean nextBean = cBean.getNextRecordedUrlBean(uBean);
+ String clickOnload = "";
+
+ // process only if its not the last url
+ if (nextBean != null) {
+ String from = nextBean.getFrom();
+ String fromHash = nextBean.getHash();
+ // case of link
+ if (from.equalsIgnoreCase(WebConstants.FROM_LINK)) {
+ // id of link = builded hash
+ clickOnload = "document.getElementById('" +
fromHash + "').click();";
+ }
+ else {
+ //case of form
+ FormParamBean fBean =
uBean.getSubmittedParamBean(fromHash);
+ if (fBean != null) {
+ String name = fBean.getName();
+ String formParentName =
fBean.getFormParentName();
+ String formParentId =
fBean.getFormParentId();
+ if (formParentName == null ||
formParentName.equalsIgnoreCase("")) {
+ clickOnload =
"document.getElementById('" + formParentId + "')" + "." + name + ".click();";
+ }
+ else {
+ clickOnload = "document." +
formParentName + "." + name + ".click();";
+ }
+ }
+ else {
+ logger.warn("submit button not found");
+ //getFormNameFormHash(fromHash);
+ String submittedFormName =
HashUtilities.getFormNameFromHash(fromHash);
+ if (submittedFormName != null) {
+ clickOnload = "document." +
submittedFormName + ".submit();";
+ }
+ else {
+ String submittedFormId =
HashUtilities.getFormIdFromHash(fromHash);
+ clickOnload =
"document.getElementById('" + submittedFormId + "')" + ".submit();";
+ }
+
+ }
+ }
+
+ // set the onload attribute
+ try {
+ String charSet = "";
+ Parser parser = Parser.createParser(html,
charSet);
+ NodeIterator it = parser.elements();
+ Html htmlTag = null;
+ while (it.hasMoreNodes()) {
+ Node n = it.nextNode();
+ if (n instanceof Html) {
+ htmlTag = (Html) n;
+ NodeIterator itt =
parser.elements();
+ while (itt.hasMoreNodes()) {
+ Node nn = it.nextNode();
+ if (nn instanceof
BodyTag) {
+ Tag tag =
(BodyTag) nn;
+ String onload =
tag.getAttribute("onload");
+ if (onload ==
null) {
+ onload
= clickOnload;
+ }
+ else {
+ onload
= onload + ";" + clickOnload;
+ }
+
tag.setAttribute("onload", onload);
+
//+"alert('coucou c'est nous!!');");
+
logger.debug("[New Onload: " + onload + " ]");
+
+ }
+
+ }
+ }
+
+ }
+ return htmlTag.toHtml();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ return "Excepton has occured when setting on
load!!";
+ }
+
+ }
+
+ return "No document";
+ }
+
+
/**
* Description of the Method
*
@@ -375,36 +443,36 @@
private HTMLDocument updateUrlBeanAndGetDoument(HttpServletRequest
httpServletRequest, HttpServletResponse httpServletResponse, UrlBean uBean)
throws Exception {
uBean.setQueryParamListFromMap(getParam(httpServletRequest));
- // get the URLWrapper object
+ // get the URLWrapper object
String hash = uBean.getHash();
- logger.debug("looking for urlwrapper whit hash: "+hash);
+ logger.debug("looking for urlwrapper whit hash: " + hash);
URLWrapper uw =
getURLMap(httpServletRequest).getSourceUrl(uBean.getHash());
- // get from and http method
- String from = uBean.getFrom();
+ // get from and http method
+ String from = uBean.getFrom();
String httpMethod = "GET";
- String url = uBean.getUrlValue();
+ String url = uBean.getUrlValue();
if (uw == null) {
logger.debug("URLWrapper not found: it must be the
first step");
- }else{
- // update value from the URLWrapper
- httpMethod = uw.getMethod();
- url = uw.getSourceUrl();
- uBean.setUrlValue(url);
- }
-
+ }
+ else {
+ // update value from the URLWrapper
+ httpMethod = uw.getMethod();
+ url = uw.getSourceUrl();
+ uBean.setUrlValue(url);
+ }
//update the url
uBean.setUrlValue(url);
logger.debug("[ URL is: " + url + " ]");
logger.debug("WebBrowser action: from: " + from);
logger.debug("WebBrowse action: hash: " + hash);
- logger.debug("WebBrowser action: method: " + from);
+ logger.debug("WebBrowser action: method: " + from);
//Get the HTMLDocument
Hashtable headerParamHash = getHeaderParams(request);
- HTMLDocument htmlDocument =
buildTransformedDocument(httpServletRequest, httpServletResponse, uBean,
httpMethod, "sessionId", headerParamHash);
+ HTMLDocument htmlDocument = buildDocument(httpServletRequest,
httpServletResponse, uBean, httpMethod, "sessionId", headerParamHash);
uBean.setDocument(htmlDocument);
return htmlDocument;
@@ -431,7 +499,7 @@
String sessionId = request.getSession().getId();
//build the document
- HTMLDocument doc = buildTransformedDocument(request, response,
uBean, "GET", sessionId, headerParamHash);
+ HTMLDocument doc = buildDocument(request, response, uBean,
"GET", sessionId, headerParamHash);
return doc;
}
@@ -448,7 +516,7 @@
[EMAIL PROTECTED] Description of the Returned Value
[EMAIL PROTECTED] Exception Description of Exception
*/
- private HTMLDocument buildTransformedDocument(HttpServletRequest
request, HttpServletResponse response, UrlBean uBean, String httpMethod, String
sessionId, Hashtable headerParamHash) throws Exception {
+ private HTMLDocument buildDocument(HttpServletRequest request,
HttpServletResponse response, UrlBean uBean, String httpMethod, String
sessionId, Hashtable headerParamHash) throws Exception {
// Get a HMTLDocument builder
HTMLDocumentBuilder builder = new HTMLDocumentBuilder(uBean,
httpMethod);
Index: ChewExtractorFilter.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/ChewExtractorFilter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ChewExtractorFilter.java 23 Jun 2005 16:15:49 -0000 1.4
+++ ChewExtractorFilter.java 24 Jun 2005 13:37:40 -0000 1.5
@@ -171,7 +171,7 @@
setStyleAndPosition(tag, visibility,
position);
}
else {
- setStyleAndPosition(tag, "visibility:
hidden;", "");
+ // setStyleAndPosition(tag, "visibility:
hidden;", "");
}
countTable++;
}
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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DefaultHTMLTransformer.java 23 Jun 2005 16:15:49 -0000 1.12
+++ DefaultHTMLTransformer.java 24 Jun 2005 13:37:40 -0000 1.13
@@ -382,7 +382,7 @@
if (type != null) {
if (!editableInputParameter(type)) {
- return;
+ visibility = "false";
}
}
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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HTMLParserTransformer.java 23 Jun 2005 16:15:50 -0000 1.9
+++ HTMLParserTransformer.java 24 Jun 2005 13:37:41 -0000 1.10
@@ -116,6 +116,7 @@
String charSet = "";
Parser parser =
Parser.createParser(getDocument().getOriginalDocumentAsString(), charSet);
TransformBuilderVisitor visitor = new
TransformBuilderVisitor(this);
+
try {
parser.visitAllNodesWith(visitor);
String transformedHTML =
visitor.getFirstNode().toHtml();
Index: UserBuilderVisitor.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/UserBuilderVisitor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UserBuilderVisitor.java 23 Jun 2005 16:15:50 -0000 1.1
+++ UserBuilderVisitor.java 24 Jun 2005 13:37:41 -0000 1.2
@@ -54,12 +54,12 @@
// process body tag
if (tag instanceof BodyTag) {
- try {
+ /* try {
processBodyTag((BodyTag) tag);
}
catch (WebClippingException ex) {
getTransformer().addParsingErrors(ex.getMessage());
- }
+ }*/
}
// process ele whith attribut href
else if (tag.getAttribute("href") != null) {
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DomHTMLTransformer.java 23 Jun 2005 16:15:51 -0000 1.7
+++ DomHTMLTransformer.java 24 Jun 2005 13:37:41 -0000 1.8
@@ -34,6 +34,11 @@
private final String SYTLE_ELE_XPATH = "//style";
private final String SCRIPT_ELE_XPATH = "//script";
private final String CHEW_ELE_XPATH = "//table";
+ /**
+ * Description of the Field
+ */
+ public static String JAVASCRIPT_EVENT_XPATH =
+
"//@onAbort|//@onBlur|//@onChange|//@onClick|//@onDblClick|//@onDragDrop|//@onError|//@onFocus|//@onKeyDown|//@onKeyPress|//@onKeyUp|//@onLoad|//@onMouseDown|//@onMouseMove|//@onMouseOut|//@onMouseOver|//@onMouseUp|//@onMove|//@onReset|
//@onResize|//@onSelect|//@onSubmit|//@onUnload";
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(DomHTMLTransformer.class);
@@ -146,10 +151,11 @@
processUserInputElement(userDocument);
// process the body tag by adding onload att
- processUserBodyElement(userDocument);
+ //processUserBodyElement(userDocument);
//Rewrite urls
processHrefAttribute(userDocument,
Constants.WEB_BROWSER_SHOW_TEST);
+ processJavascriptEvent(userDocument,
Constants.WEB_BROWSER_SHOW_TEST);
processSytleElement(userDocument);
processSrcAttribute(userDocument);
@@ -253,6 +259,7 @@
processSytleElement(transformedDocument);
//processScriptElement(transformedDocument);
processHrefAttribute(transformedDocument,
Constants.WEB_BROWSER_SHOW_BROWSE);
+ processJavascriptEvent(transformedDocument,
Constants.WEB_BROWSER_SHOW_BROWSE);
}
@@ -491,7 +498,7 @@
if (id == null ||
id.equalsIgnoreCase("")) {
att.getOwnerElement().setAttribute("id", linkHash);
}
-
att.getOwnerElement().removeAttribute("target");
+
att.getOwnerElement().removeAttribute("target");
pos++;
}
att.setNodeValue(getRewritedHrefValue(ownerTagName, att.getNodeValue(), id,
position, webBrowseAction));
@@ -507,6 +514,33 @@
/**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] doc Description of Parameter
+ [EMAIL PROTECTED] webBrowseAction Description of Parameter
+ */
+ private void processJavascriptEvent(Document doc, String
webBrowseAction) {
+ logger.debug("[ Process href att ]");
+ NodeList atts = DomUtilities.getNodeListByXPath(doc,
JAVASCRIPT_EVENT_XPATH);
+ for (int i = 0; i < atts.getLength(); i++) {
+ try {
+ Attr att = (Attr) atts.item(i);
+ String value = att.getValue();
+ String refactoredValue =
getRefactoredJavascript(getUrlBean().getUrlValue(), webBrowseAction, value);
+ att.setNodeValue(value);
+
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ addParsingErrors("href attribute rewriting
error: " + ex.toString());
+ }
+ }
+
+ }
+
+
+
+ /**
* Rewrite action attribute
*/
/*
@@ -866,6 +900,7 @@
String formId = formEle.getAttribute("id");
formEle.setAttribute("action",
getRewritedActionValue(url, method, formName, formId, webBrowserAction));
formEle.setAttribute("method", "post");
+ formEle.removeAttribute("target");
}
catch (Exception ex) {
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HttpProcessor.java 23 Jun 2005 16:15:51 -0000 1.6
+++ HttpProcessor.java 24 Jun 2005 13:37:41 -0000 1.7
@@ -34,7 +34,7 @@
// redirection
private GetMethod redirect = null;
- private HTMLDocument htmlDocument;
+
//state
private HttpState stateBeforeExecution;
@@ -136,14 +136,6 @@
}
- /**
- * Sets the HtmlDocument attribute of the HttpProcessor object
- *
- [EMAIL PROTECTED] htmlDocument The new HtmlDocument value
- */
- public void setHtmlDocument(HTMLDocument htmlDocument) {
- this.htmlDocument = htmlDocument;
- }
@@ -254,18 +246,7 @@
}
- /**
- * Gets the HtmlDocument attribute of the HttpProcessor object
- *
- [EMAIL PROTECTED] The HtmlDocument value
- [EMAIL PROTECTED] WebClippingException Description of Exception
- */
- public HTMLDocument getHtmlDocument() throws WebClippingException {
- if (htmlDocument == null) {
- execute(getNewHttpClient());
- }
- return htmlDocument;
- }
+
@@ -550,15 +531,15 @@
Cookie[] cookiess = s.getCookies();
- logger.debug("[ Begin Enumerate cookies before execution ]");
+ logger.debug("[ HttpClient: Begin Enumerate cookies before
execution ]");
for (int i = 0; i < cookiess.length; i++) {
Cookie c = cookiess[i];
logger.debug("[ Found cookie before execution: " +
c.getName() + " ]");
}
+ logger.debug("[ HttpClient: Finish Enumerate cookies before
execution ]");
// Init
String html = null;
- HTMLDocument htmlDocument = null;
try {
// Execute the method.
@@ -596,8 +577,8 @@
// Get the reponse
html =
redirect.getResponseBodyAsString();
- logger.debug("[ Redirect: " +
redirect.getStatusLine().toString() +
- " ]");
+ logger.debug("[ Redirect: " +
redirect.getStatusLine().toString() +" ]");
+
// set redirectedUrl
getUrlBean().setRedirectUrl(URLUtilities.getURL(newuri));
@@ -649,9 +630,6 @@
redirect.releaseConnection();
}
- // set the document
- setHtmlDocument(htmlDocument);
-
//HttpState
HttpState state = getDefaultClient().getState();
Cookie[] cookies = state.getCookies();
Index: editAction.jsp
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/webapp/jsp/actions/editAction.jsp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- editAction.jsp 23 Jun 2005 16:15:52 -0000 1.5
+++ editAction.jsp 24 Jun 2005 13:37:42 -0000 1.6
@@ -67,15 +67,19 @@
<html:optionsCollection name="clipperBean"
property="urlListBean" value="position" label="labelForStrut"/>
</html:select>
<!-- Show hmtl-->
- <!-- <html:checkbox property="showHTML" value="true"
onclick="setActionAndSubmit(this.form,'changeView')">
+ <!--
+ <html:checkbox property="showHTML" value="true"
onclick="setActionAndSubmit(this.form,'changeView')">
<bean:message key="edit.ShowHTML"/>
- </html:checkbox>
- <logic:equal name="editParamForm" property="showHTML"
value="true">-->
- <!-- Show param label-->
- <!-- <html:checkbox property="showLabel" value="true"
onclick="setActionAndSubmit(this.form,'changeView')">
- <bean:message key="edit.ShowLabel"/>
</html:checkbox>
- </logic:equal>-->
+ <logic:equal name="editParamForm" property="showHTML"
value="true">
+ -->
+ <!-- Show param label-->
+ <!--
+ <html:checkbox property="showLabel" value="true"
onclick="setActionAndSubmit(this.form,'changeView')">
+ <bean:message key="edit.ShowLabel"/>
+ </html:checkbox>
+ </logic:equal>
+ -->
</td>
</tr>
</table>
@@ -156,12 +160,6 @@
</logic:iterate> </table>
</table>
-</html:form></table><!-- HTML part -->
-<!--<logic:equal name="editParamForm" property="showHTML" value="true">
- <logic:equal name="editParamForm" property="showLabel" value="true">
- <iframe
src="<%=response.encodeURL(request.getContextPath()+"/webBrowser.do")%>"
width="100%" height="100%" frameborder="1" scrolling="auto"> </iframe>
- </logic:equal>
- <logic:equal name="editParamForm" property="showLabel" value="false">-->
- <iframe
src="<%=response.encodeURL(request.getContextPath()+"/webBrowser.do")%>"
width="100%" height="100%" frameborder="1" scrolling="auto"> </iframe>
- <!--</logic:equal>
-</logic:equal>-->
+</html:form></table>
+<!-- HTML part -->
+<iframe
src="<%=response.encodeURL(request.getContextPath()+"/webBrowser.do")%>"
width="100%" height="100%" frameborder="1" scrolling="auto"></iframe>
Index: testClipperAction.jsp
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/webapp/jsp/actions/testClipperAction.jsp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- testClipperAction.jsp 23 Jun 2005 16:15:52 -0000 1.5
+++ testClipperAction.jsp 24 Jun 2005 13:37:42 -0000 1.6
@@ -95,7 +95,7 @@
<!-- Values-->
<logic:notEqual name="currentParam" property="type"
value="password">
<td class="leftlevel2 waInput">
- <bean:write name="currentParam" property="usedValue"/>
+ <html:text name="currentParam" property="usedValue"/>
</td>
</logic:notEqual>
<logic:equal name="currentParam" property="type"
value="password">