A few related changes:
Big refactor of ControlServlet, RequestManager, RequestHandler, and ConfigXMLReader so that simple objects are used instead of Maps within Maps within Maps for the data from the controller.xml file, which results in eliminating hundreds of lines of code including the entire RequestHandler class. I have tested this a lot with different apps that use the ControlServlet differently, but this is a very big change so there could still be issues. Based on this cleanup future issues and new features should be easier and less error prone, and that is why doing it now in order to help with a number of other improvements and bug fixes that are part of this commit. Also added redirect-parameter element to go under the request-map -> response element which allows you to specify which parameters will be passed on in a redirect instead of using all of them. Also improved default there and in various places to only include parameters from the URL to avoid issues with form data, but if the ID to display (like following a crAlso added redirect-parameter element to go under the request-map -> response element which allows you to specify which parameters will be passed on in a redirect instead of using all of them. Also improved default there and in various places to only include parameters from the URL to avoid issues with form data, but if the ID to display (like following a crAlso added redirect-parameter element to go under the request-map -> response element which allows you to specify which parameters will be passed on in a redirect instead of using all of them. Also improved default there and in various places to only include parameters from the URL to avoid issues wd in and also going to the same page after login from auth=true or from clicking on the login link. Related to cleaning up login URLs also changed how the request and parameters passed to a request before a login are saved and used after a login is successful so that it URL parameters go on the URL in a redirect to the original request to make it more transparent, and non-URL parameters just stay in the session and are used when the original request is run again to avoid putting sensitive information like passwords and big information like textarea data in the URL, which has been a problem before. To see what some of these things combined can do try going to the example app, login, click on the New Example link, then logout in another tab or window, then go back to the New Example page and enter a name and a whole bunch of text in the long description then click Create, the system will show you the login page so enter username/password, and then after login you'll see a nice URL to EditExample with the correct exampleId parameter and all of the data entered before login successfully saved and never appearing in a URL. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@741374 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -19,9 +19,7 @@
|
||||
package org.ofbiz.webtools.artifactinfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
@@ -34,12 +32,11 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
import javolution.util.FastSet;
|
||||
import javolution.util.FastList;
|
||||
|
||||
import org.ofbiz.base.component.ComponentConfig;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.GeneralException;
|
||||
import org.ofbiz.base.util.FileUtil;
|
||||
import org.ofbiz.base.util.GeneralException;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.base.util.cache.UtilCache;
|
||||
import org.ofbiz.entity.GenericEntityException;
|
||||
@@ -215,14 +212,14 @@ public class ArtifactInfoFactory {
|
||||
throw new GeneralException(mue.getMessage());
|
||||
}
|
||||
ControllerConfig cc = ConfigXMLReader.getControllerConfig(controllerUrl);
|
||||
for (String requestUri: cc.requestMap.keySet()) {
|
||||
for (String requestUri: cc.requestMapMap.keySet()) {
|
||||
try {
|
||||
this.getControllerRequestArtifactInfo(controllerUrl, requestUri);
|
||||
} catch(GeneralException e) {
|
||||
Debug.logWarning(e.getMessage(), module);
|
||||
}
|
||||
}
|
||||
for (String viewUri: cc.viewMap.keySet()) {
|
||||
for (String viewUri: cc.viewMapMap.keySet()) {
|
||||
try {
|
||||
this.getControllerViewArtifactInfo(controllerUrl, viewUri);
|
||||
} catch(GeneralException e) {
|
||||
@@ -261,13 +258,13 @@ public class ArtifactInfoFactory {
|
||||
return ScreenFactory.getScreenFromLocation(screenLocation, screenName);
|
||||
}
|
||||
|
||||
public Map<String, Object> getControllerRequestInfoMap(URL controllerXmlUrl, String requestUri) {
|
||||
return ConfigXMLReader.getControllerConfig(controllerXmlUrl).requestMap.get(requestUri);
|
||||
public ConfigXMLReader.RequestMap getControllerRequestMap(URL controllerXmlUrl, String requestUri) {
|
||||
return ConfigXMLReader.getControllerConfig(controllerXmlUrl).requestMapMap.get(requestUri);
|
||||
}
|
||||
|
||||
public Map<String, String> getControllerViewInfoMap(URL controllerXmlUrl, String viewUri) {
|
||||
public ConfigXMLReader.ViewMap getControllerViewMap(URL controllerXmlUrl, String viewUri) {
|
||||
ControllerConfig cc = ConfigXMLReader.getControllerConfig(controllerXmlUrl);
|
||||
return cc.viewMap.get(viewUri);
|
||||
return cc.viewMapMap.get(viewUri);
|
||||
}
|
||||
|
||||
public EntityArtifactInfo getEntityArtifactInfo(String entityName) throws GeneralException {
|
||||
|
||||
+14
-14
@@ -41,7 +41,7 @@ public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
|
||||
protected URL controllerXmlUrl;
|
||||
protected String requestUri;
|
||||
|
||||
protected Map<String, Object> requestInfoMap;
|
||||
protected ConfigXMLReader.RequestMap requestInfoMap;
|
||||
|
||||
protected ServiceArtifactInfo serviceCalledByRequestEvent = null;
|
||||
protected Set<ControllerRequestArtifactInfo> requestsThatAreResponsesToThisRequest = new TreeSet<ControllerRequestArtifactInfo>();
|
||||
@@ -52,7 +52,7 @@ public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
|
||||
this.controllerXmlUrl = controllerXmlUrl;
|
||||
this.requestUri = requestUri;
|
||||
|
||||
this.requestInfoMap = aif.getControllerRequestInfoMap(controllerXmlUrl, requestUri);
|
||||
this.requestInfoMap = aif.getControllerRequestMap(controllerXmlUrl, requestUri);
|
||||
|
||||
if (this.requestInfoMap == null) {
|
||||
throw new GeneralException("Controller request with name [" + requestUri + "] is not defined in controller file [" + controllerXmlUrl + "].");
|
||||
@@ -67,8 +67,8 @@ public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
|
||||
public void populateAll() throws GeneralException {
|
||||
// populate serviceCalledByRequestEvent, requestsThatAreResponsesToThisRequest, viewsThatAreResponsesToThisRequest and related reverse maps
|
||||
|
||||
if ("service".equals(this.requestInfoMap.get(ConfigXMLReader.EVENT_TYPE))) {
|
||||
String serviceName = (String) this.requestInfoMap.get(ConfigXMLReader.EVENT_METHOD);
|
||||
if ("service".equals(this.requestInfoMap.event.type)) {
|
||||
String serviceName = (String) this.requestInfoMap.event.invoke;
|
||||
try {
|
||||
this.serviceCalledByRequestEvent = this.aif.getServiceArtifactInfo(serviceName);
|
||||
if (this.serviceCalledByRequestEvent != null) {
|
||||
@@ -80,10 +80,10 @@ public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> responseMap = UtilGenerics.checkMap(this.requestInfoMap.get(ConfigXMLReader.RESPONSE_MAP));
|
||||
for (String responseValue: responseMap.values()) {
|
||||
if (responseValue.startsWith("view:")) {
|
||||
String viewUri = responseValue.substring(5);
|
||||
Map<String, ConfigXMLReader.RequestResponse> requestResponseMap = UtilGenerics.checkMap(this.requestInfoMap.requestResponseMap);
|
||||
for (ConfigXMLReader.RequestResponse response: requestResponseMap.values()) {
|
||||
if (response.type.equals("view")) {
|
||||
String viewUri = response.value;
|
||||
if (viewUri.startsWith("/")) {
|
||||
viewUri = viewUri.substring(1);
|
||||
}
|
||||
@@ -95,8 +95,8 @@ public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
|
||||
} catch (GeneralException e) {
|
||||
Debug.logWarning(e.toString(), module);
|
||||
}
|
||||
} else if (responseValue.startsWith("request:")) {
|
||||
String otherRequestUri = responseValue.substring(8);
|
||||
} else if (response.type.equals("request")) {
|
||||
String otherRequestUri = response.value;
|
||||
if (otherRequestUri.startsWith("/")) {
|
||||
otherRequestUri = otherRequestUri.substring(1);
|
||||
}
|
||||
@@ -107,13 +107,13 @@ public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
|
||||
} catch (GeneralException e) {
|
||||
Debug.logWarning(e.toString(), module);
|
||||
}
|
||||
} else if (responseValue.startsWith("request-redirect:")) {
|
||||
String otherRequestUri = responseValue.substring(17);
|
||||
} else if (response.type.equals("request-redirect")) {
|
||||
String otherRequestUri = response.value;
|
||||
ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);
|
||||
this.requestsThatAreResponsesToThisRequest.add(artInfo);
|
||||
UtilMisc.addToSortedSetInMap(this, this.aif.allRequestInfosReferringToRequest, artInfo.getUniqueId());
|
||||
} else if (responseValue.startsWith("request-redirect-noparam:")) {
|
||||
String otherRequestUri = responseValue.substring(25);
|
||||
} else if (response.type.equals("request-redirect-noparam")) {
|
||||
String otherRequestUri = response.value;
|
||||
ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);
|
||||
this.requestsThatAreResponsesToThisRequest.add(artInfo);
|
||||
UtilMisc.addToSortedSetInMap(this, this.aif.allRequestInfosReferringToRequest, artInfo.getUniqueId());
|
||||
|
||||
+5
-8
@@ -20,7 +20,6 @@ package org.ofbiz.webtools.artifactinfo;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
@@ -40,7 +39,7 @@ public class ControllerViewArtifactInfo extends ArtifactInfoBase {
|
||||
protected URL controllerXmlUrl;
|
||||
protected String viewUri;
|
||||
|
||||
protected Map<String, String> viewInfoMap;
|
||||
protected ConfigXMLReader.ViewMap viewInfoMap;
|
||||
|
||||
protected ScreenWidgetArtifactInfo screenCalledByThisView = null;
|
||||
|
||||
@@ -49,7 +48,7 @@ public class ControllerViewArtifactInfo extends ArtifactInfoBase {
|
||||
this.controllerXmlUrl = controllerXmlUrl;
|
||||
this.viewUri = viewUri;
|
||||
|
||||
this.viewInfoMap = aif.getControllerViewInfoMap(controllerXmlUrl, viewUri);
|
||||
this.viewInfoMap = aif.getControllerViewMap(controllerXmlUrl, viewUri);
|
||||
|
||||
if (this.viewInfoMap == null) {
|
||||
throw new GeneralException("Could not find Controller View [" + viewUri + "] at URL [" + controllerXmlUrl.toExternalForm() + "]");
|
||||
@@ -59,11 +58,9 @@ public class ControllerViewArtifactInfo extends ArtifactInfoBase {
|
||||
throw new GeneralException("Controller view with name [" + viewUri + "] is not defined in controller file [" + controllerXmlUrl + "].");
|
||||
}
|
||||
// populate screenCalledByThisView and reverse in aif.allViewInfosReferringToScreen
|
||||
if ("screen".equals(this.viewInfoMap.get(ConfigXMLReader.VIEW_TYPE)) ||
|
||||
"screenfop".equals(this.viewInfoMap.get(ConfigXMLReader.VIEW_TYPE)) ||
|
||||
"screentext".equals(this.viewInfoMap.get(ConfigXMLReader.VIEW_TYPE)) ||
|
||||
"screenxml".equals(this.viewInfoMap.get(ConfigXMLReader.VIEW_TYPE))) {
|
||||
String fullScreenName = this.viewInfoMap.get(ConfigXMLReader.VIEW_PAGE);
|
||||
if ("screen".equals(this.viewInfoMap.type) || "screenfop".equals(this.viewInfoMap.type) ||
|
||||
"screentext".equals(this.viewInfoMap.type) || "screenxml".equals(this.viewInfoMap.type)) {
|
||||
String fullScreenName = this.viewInfoMap.page;
|
||||
if (UtilValidate.isNotEmpty(fullScreenName)) {
|
||||
int poundIndex = fullScreenName.indexOf('#');
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user