Fix purely empty whitespace lines, and remove trailing whitespace.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@757086 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2009-03-21 23:43:51 +00:00
parent ebd403b00d
commit cee09e0576
53 changed files with 1071 additions and 1071 deletions
+61 -61
View File
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -36,82 +36,82 @@ import java.util.Map;
* Control Applet - Client applet for page pushing and (future) chat
*/
public class ControlApplet extends Applet implements Runnable {
private static String pushUrl = "/commonapp/control/pushapplet";
private static String pullUrl = "/commonapp/control/pullapplet";
protected AppletContext ctx = null;
protected String sessionId = null;
protected String visitId = null;
protected String serverUrl = null;
protected String serverUrl = null;
protected String timeoutUrl = null;
protected String currentPage = null;
protected String currentPage = null;
protected String debug = null;
protected int waitTime = 1500;
protected int timeout = 300000;
protected boolean isRunning = false;
protected boolean stopped = true;
protected Thread thread = null;
public void init() {
ctx = this.getAppletContext();
this.sessionId = this.getParameter("sessionId");
this.visitId = this.getParameter("visitId");
this.serverUrl = this.getParameter("serverUrl");
this.timeoutUrl = this.getParameter("timeoutUrl");
this.currentPage = this.getParameter("currentPage");
this.serverUrl = this.getParameter("serverUrl");
this.timeoutUrl = this.getParameter("timeoutUrl");
this.currentPage = this.getParameter("currentPage");
this.debug = this.getParameter("debug");
// see if we override the integer values
try {
int waitInt = Integer.parseInt(this.getParameter("waitTime"));
if (waitInt > 0)
waitTime = waitInt;
waitTime = waitInt;
} catch (NumberFormatException e) {
}
try {
int outInt = Integer.parseInt(this.getParameter("timeout"));
if (outInt > 0)
if (outInt > 0)
timeout = outInt;
} catch (NumberFormatException e) {
}
if (serverUrl != null) {
boolean sessionOkay = false;
boolean visitOkay = false;
boolean pageOkay = false;
boolean pageOkay = false;
if (sessionId != null && sessionId.length() > 0)
sessionOkay = true;
if (visitId != null && visitId.length() > 0)
visitOkay = true;
if (currentPage != null && currentPage.length() > 0)
pageOkay = true;
if (sessionOkay && visitOkay && pageOkay) {
visitOkay = true;
if (currentPage != null && currentPage.length() > 0)
pageOkay = true;
if (sessionOkay && visitOkay && pageOkay) {
// tell the host about our current page (mainly for followers)
this.push();
}
// start the polling thread
this.isRunning = true;
this.stopped = false;
thread = new Thread(this);
thread.setDaemon(false);
thread.setDaemon(false);
thread.start();
}
}
}
public void destroy() {
this.stopped = true;
this.stopped = true;
}
// poll the servlet for page request
public void run() {
public void run() {
while (isRunning && !stopped) {
this.pull();
try {
@@ -119,55 +119,55 @@ public class ControlApplet extends Applet implements Runnable {
} catch (InterruptedException e) {
this.stopped = true;
this.isRunning = false;
}
}
}
if (debug != null && debug.equalsIgnoreCase("true"))
System.out.println("Polling finished.");
}
protected void pull() {
protected void pull() {
Map params = new HashMap();
params.put("sessionId", this.sessionId.trim());
params.put("visitId", this.visitId.trim());
String pullResp = null;
URL callPullUrl = null;
try {
callPullUrl = new URL(serverUrl + pullUrl);
} catch (MalformedURLException e) {
}
if (callPullUrl != null) {
try {
pullResp = callServer(callPullUrl, params);
} catch (IOException e) {
}
}
}
if (pullResp != null && pullResp.length() > 0) {
URL docUrl = null;
try {
docUrl = new URL(pullResp);
} catch (MalformedURLException e) {
}
if (docUrl != null)
if (docUrl != null)
ctx.showDocument(docUrl, "appletWindow");
}
}
protected void push() {
Map params = new HashMap();
Map params = new HashMap();
params.put("sessionId", this.sessionId.trim());
params.put("visitId", this.visitId.trim());
params.put("currentPage", this.currentPage.trim());
params.put("visitId", this.visitId.trim());
params.put("currentPage", this.currentPage.trim());
String pushResp = null;
URL callPushUrl = null;
try {
callPushUrl = new URL(serverUrl + pushUrl);
callPushUrl = new URL(serverUrl + pushUrl);
} catch (MalformedURLException e) {
}
if (callPushUrl != null) {
try {
pushResp = callServer(callPushUrl, params);
@@ -175,19 +175,19 @@ public class ControlApplet extends Applet implements Runnable {
}
}
}
private String callServer(URL serverUrl, Map parms) throws IOException {
// send the request
String parameters = this.encodeArgs(parms);
if (debug != null && debug.equalsIgnoreCase("true"))
System.out.println("Sending parameters: " + parameters);
private String callServer(URL serverUrl, Map parms) throws IOException {
// send the request
String parameters = this.encodeArgs(parms);
if (debug != null && debug.equalsIgnoreCase("true"))
System.out.println("Sending parameters: " + parameters);
URLConnection uc = serverUrl.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
PrintWriter pw = new PrintWriter(uc.getOutputStream());
pw.println(parameters);
pw.close();
// read the response
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String responseStr = in.readLine();
@@ -195,10 +195,10 @@ public class ControlApplet extends Applet implements Runnable {
if (responseStr != null)
responseStr = responseStr.trim();
if (debug != null && debug.equalsIgnoreCase("true"))
System.out.println("Receive response: " + responseStr);
return responseStr;
System.out.println("Receive response: " + responseStr);
return responseStr;
}
public String encodeArgs(Map args) {
StringBuffer buf = new StringBuffer();
if (args != null) {
@@ -214,24 +214,24 @@ public class ControlApplet extends Applet implements Runnable {
} else {
valueStr = value.toString();
}
if (valueStr != null && valueStr.length() > 0) {
if (buf.length() > 0) buf.append('&');
try {
buf.append(URLEncoder.encode(name, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
e.printStackTrace();
}
buf.append('=');
try {
buf.append(URLEncoder.encode(valueStr, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
}
return buf.toString();
}
}
}