List of usage examples for com.google.gwt.http.client URL decodeQueryString
public static String decodeQueryString(String encodedURLComponent)
From source file:org.opencms.ade.containerpage.client.CmsContentEditorHandler.java
License:Open Source License
/** * Opens the XML content editor.<p> * * @param editableData the data of the element to edit * @param isNew <code>true</code> if a new resource should be created * @param dependingElementId the id of a depending element * @param mode the element creation mode *//*from w w w . j a v a 2 s.c om*/ public void openDialog(final I_CmsEditableData editableData, final boolean isNew, String dependingElementId, String mode) { if (!m_editorOpened) { m_editorOpened = true; m_handler.disableToolbarButtons(); m_handler.deactivateCurrentButton(); if ((editableData.getStructureId() != null) && !isNew) { m_currentElementId = editableData.getStructureId().toString(); } else { m_currentElementId = null; } m_dependingElementId = dependingElementId; if (m_handler.m_controller.getData().isUseClassicEditor()) { CmsContentEditorDialog.get().openEditDialog(editableData, isNew, mode, new DialogOptions(), this); } else { String newLink = null; if (isNew) { newLink = editableData.getNewLink(); // the new link is URL encoded twice, decode it newLink = URL.decodeQueryString(newLink); newLink = URL.decodeQueryString(newLink); } addEditingHistoryItem(isNew); CmsContentEditor.getInstance().openFormEditor(getEditorContext(), CmsCoreProvider.get().getLocale(), editableData.getStructureId().toString(), newLink, null, editableData.getPostCreateHandler(), mode, m_handler.m_controller.getData().getMainLocale(), new Command() { public void execute() { addClosedEditorHistoryItem(); onClose(editableData.getSitePath(), editableData.getStructureId(), isNew); } }); } } else { CmsDebugLog.getInstance().printLine("Editor is already being opened."); } }
From source file:org.overlord.sramp.ui.client.places.PlaceUtils.java
License:Apache License
/** * Parses the place token into a map of query parameters. The expected format of any place token is a * standard URL query-parameter formatted string. * /*from ww w . j a v a 2 s . c om*/ * @param placeToken the place token * @return a map of query params */ @SuppressWarnings("unchecked") public static Map<String, String> parsePlaceToken(String placeToken) { if (placeToken == null || placeToken.trim().length() == 0) return Collections.EMPTY_MAP; Map<String, String> queryParams = new HashMap<String, String>(); String[] paramSplits = placeToken.split("&"); if (paramSplits.length > 0) { for (String paramSplit : paramSplits) { String[] split2 = paramSplit.split("="); if (split2.length == 2) { String key = split2[0]; String encodedValue = split2[1]; String value = URL.decodeQueryString(encodedValue); queryParams.put(key, value); } } } return queryParams; }
From source file:org.pentaho.mantle.client.MantleApplication.java
License:Open Source License
public void onMantleSettingsLoaded(MantleSettingsLoadedEvent event) { final HashMap<String, String> settings = event.getSettings(); final boolean showOnlyPerspective = Boolean .parseBoolean(StringUtils.isEmpty(Window.Location.getParameter("showOnlyPerspective")) ? settings.get("showOnlyPerspective") : Window.Location.getParameter("showOnlyPerspective")); final String startupPerspective = StringUtils.isEmpty(Window.Location.getParameter("startupPerspective")) ? settings.get("startupPerspective") : Window.Location.getParameter("startupPerspective"); mantleRevisionOverride = settings.get("user-console-revision"); RootPanel.get("pucMenuBar").add(MantleXul.getInstance().getMenubar()); RootPanel.get("pucPerspectives").add(PerspectiveManager.getInstance()); RootPanel.get("pucToolBar").add(MantleXul.getInstance().getToolbar()); RootPanel.get("pucUserDropDown").add(new UserDropDown()); if (showOnlyPerspective && !StringUtils.isEmpty(startupPerspective)) { RootPanel.get("pucHeader").setVisible(false); RootPanel.get("pucContent").getElement().getStyle().setTop(0, Unit.PX); }/*from ww w. ja v a 2 s.com*/ // update supported file types PluginOptionsHelper.buildEnabledOptionsList(settings); // show stuff we've created/configured contentDeck.add(new Label()); contentDeck.showWidget(0); contentDeck.add(SolutionBrowserPanel.getInstance()); if (showOnlyPerspective && !StringUtils.isEmpty(startupPerspective)) { SolutionBrowserPanel.getInstance().setVisible(false); } contentDeck.getElement().setId("applicationShell"); contentDeck.setStyleName("applicationShell"); // menubar=no,location=no,resizable=yes,scrollbars=no,status=no,width=1200,height=800 try { RootPanel.get("pucContent").add(contentDeck); } catch (Throwable t) { // onLoad of something is causing problems } RootPanel.get().add(WaitPopup.getInstance()); // Add in the overlay panel overlayPanel.setVisible(false); overlayPanel.setHeight("100%"); overlayPanel.setWidth("100%"); overlayPanel.getElement().getStyle().setProperty("zIndex", "1000"); overlayPanel.getElement().getStyle().setProperty("position", "absolute"); RootPanel.get().add(overlayPanel, 0, 0); String submitOnEnterSetting = settings.get("submit-on-enter-key"); submitOnEnter = submitOnEnterSetting == null ? submitOnEnter : Boolean.parseBoolean(submitOnEnterSetting); try { String restUrl = GWT.getHostPageBaseURL() + "api/repo/files/canAdminister"; //$NON-NLS-1$ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, restUrl); requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onError(Request arg0, Throwable arg1) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ arg1.getLocalizedMessage(), false, false, true); dialogBox.center(); } @Override public void onResponseReceived(Request arg0, Response response) { Boolean isAdministrator = Boolean.parseBoolean(response.getText()); SolutionBrowserPanel.getInstance().setAdministrator(isAdministrator); try { String restUrl2 = GWT.getHostPageBaseURL() + "api/scheduler/canSchedule"; //$NON-NLS-1$ RequestBuilder requestBuilder2 = new RequestBuilder(RequestBuilder.GET, restUrl2); requestBuilder2.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder2.sendRequest(null, new RequestCallback() { @Override public void onError(Request arg0, Throwable arg1) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ arg1.getLocalizedMessage(), false, false, true); dialogBox.center(); } public void onResponseReceived(Request arg0, Response response) { Boolean isScheduler = Boolean.parseBoolean(response.getText()); SolutionBrowserPanel.getInstance().setScheduler(isScheduler); String numStartupURLsSetting = settings.get("num-startup-urls"); if (numStartupURLsSetting != null) { int numStartupURLs = Integer.parseInt(numStartupURLsSetting); //$NON-NLS-1$ for (int i = 0; i < numStartupURLs; i++) { String url = settings.get("startup-url-" + (i + 1)); //$NON-NLS-1$ String name = settings.get("startup-name-" + (i + 1)); //$NON-NLS-1$ if (StringUtils.isEmpty(url) == false) { //$NON-NLS-1$ url = URL.decodeQueryString(url); name = URL.decodeQueryString(name); SolutionBrowserPanel.getInstance().getContentTabPanel() .showNewURLTab(name != null ? name : url, url, url, false); } } } if (SolutionBrowserPanel.getInstance().getContentTabPanel().getWidgetCount() > 0) { SolutionBrowserPanel.getInstance().getContentTabPanel().selectTab(0); } // startup-url on the URL for the app, wins over settings String startupURL = Window.Location.getParameter("startup-url"); //$NON-NLS-1$ if (startupURL != null && !"".equals(startupURL)) { //$NON-NLS-1$ // Spaces were double encoded so that they wouldn't be replaced with '+' when creating a deep // link so when following a deep link we need to replace '%20' with a space even after decoding String title = Window.Location.getParameter("name").replaceAll("%20", " "); //$NON-NLS-1$ SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(title, title, startupURL, false); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ e.getLocalizedMessage(), false, false, true); dialogBox.center(); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), e.getLocalizedMessage(), //$NON-NLS-1$ false, false, true); dialogBox.center(); } if (!StringUtils.isEmpty(startupPerspective)) { if (PerspectiveManager.getInstance().isLoaded()) { PerspectiveManager.getInstance().setPerspective(startupPerspective); } else { EventBusUtil.EVENT_BUS.addHandler(PerspectivesLoadedEvent.TYPE, new PerspectivesLoadedEventHandler() { public void onPerspectivesLoaded(PerspectivesLoadedEvent event) { PerspectiveManager.getInstance().setPerspective(startupPerspective); } }); } } }
From source file:org.pentaho.reporting.platform.plugin.gwt.client.ReportViewerUtil.java
License:Open Source License
/** * Parses the history tokens and returns a map keyed by the parameter names. The parameter values are * stored as list of strings./*from w w w . j av a 2s . co m*/ * * @return the token map. */ public static ParameterValues getHistoryTokenParameters() { final ParameterValues map = new ParameterValues(); final String historyToken = History.getToken(); if (StringUtils.isEmpty(historyToken)) { return map; } final StringTokenizer st = new StringTokenizer(historyToken, "&"); //$NON-NLS-1$ final int paramTokens = st.countTokens(); for (int i = 0; i < paramTokens; i++) { final String fullParam = st.tokenAt(i); final StringTokenizer st2 = new StringTokenizer(fullParam, "="); //$NON-NLS-1$ if (st2.countTokens() != 2) { continue; } final String name = URL.decodeQueryString(st2.tokenAt(0)); final String value = URL.decodeQueryString(st2.tokenAt(1)); map.addSelectedValue(name, value); } // tokenize this guy & and = return map; }
From source file:org.pentaho.reporting.platform.plugin.gwt.client.ReportViewerUtil.java
License:Open Source License
/** * Builds the URL that is needed to communicate with the backend. * * @param renderType the render type, never null. * @param reportParameterMap the parameter map, never null. * @return the generated URL/*from w w w.j a v a2s.c om*/ */ public static String buildReportUrl(final ReportViewer.RENDER_TYPE renderType, final ParameterValues reportParameterMap, final ParameterDefinition parameterDefinition) { final String FILES = "files/"; if (reportParameterMap == null) { throw new NullPointerException(); } String reportPath = Window.Location.getPath(); if (renderType == ReportViewer.RENDER_TYPE.PARAMETER) { reportPath = reportPath.substring(0, reportPath.lastIndexOf("/")) + "/" + renderType + "?"; } reportPath = reportPath.replace("viewer-gwt", "generatedContent"); // reportPath += "?renderMode=" + renderType; // NON-NLS // if(reportPath.indexOf("&path") < 0) { // int start = reportPath.indexOf(FILES); // int end = reportPath.lastIndexOf("/"); // String path = reportPath.substring(start+FILES.length(), end); // reportPath +="&path=" + path; // } if (reportPath.indexOf("&locale") < 0) { String localeName = StringUtils.defaultIfEmpty(Window.Location.getParameter("locale"), //$NON-NLS-1$ getLanguagePreference()); reportPath += "&locale=" + localeName; } final ParameterValues parameters = new ParameterValues(); // User submitted values always make it into the final URL .. for (final String key : reportParameterMap.getParameterNames()) { if ("renderMode".equals(key)) { continue; } final String[] valueList = reportParameterMap.getParameterValues(key); final String[] encodedList = new String[valueList.length]; for (int i = 0; i < valueList.length; i++) { final String value = valueList[i]; if (value == null) { encodedList[i] = null; //$NON-NLS-1$ } else { encodedList[i] = value; } } parameters.setSelectedValues(key, encodedList); } // history token parameters will override default parameters (already on URL) // but they will not override user submitted parameters final ParameterValues historyParams = getHistoryTokenParameters(); if (historyParams != null) { for (final String key : historyParams.getParameterNames()) { if (parameters.containsParameter(key)) { continue; } if ("renderMode".equals(key)) { continue; } final String[] valueList = historyParams.getParameterValues(key); final String[] encodedList = new String[valueList.length]; for (int i = 0; i < valueList.length; i++) { final String value = valueList[i]; if (value == null) { encodedList[i] = null; //$NON-NLS-1$ } else { encodedList[i] = (value); } } // Window.alert("History-Value: " + key); parameters.setSelectedValues(key, encodedList); } } // Last but not least - add the paramters that were given in the URL ... // The value is decoded, the parameter name is not decoded (according to the source code for GWT-2.0). final Map<String, List<String>> requestParams = Window.Location.getParameterMap(); if (requestParams != null) { for (final String rawkey : requestParams.keySet()) { final String key = URL.decodeQueryString(rawkey); if ("renderMode".equals(key)) { continue; } if ("::session".equals(key)) { // session IDs are generated on the server, not via URL. We discard all such parameters on the URL. continue; } if (parameters.containsParameter(key)) { continue; } final List<String> valueList = requestParams.get(rawkey); final String[] encodedList = new String[valueList.size()]; for (int i = 0; i < valueList.size(); i++) { final String value = valueList.get(i); if (value == null) { encodedList[i] = null; //$NON-NLS-1$ } else { encodedList[i] = (value); } } // Window.alert("Location-Value: " + key); parameters.setSelectedValues(key, encodedList); } } final String parametersAsString = parameters.toURL(); if (History.getToken().equals(parametersAsString) == false) { // don't add duplicates, only new ones // assuming that History.getToken() returns the last newItem string unchanged, // then we must not URL-encode the paramter string. History.newItem(parametersAsString, false); } reportPath += "&" + parametersAsString; if (GWT.isScript() == false) { // Build a dev/test url System.out.println("Computed path was: " + reportPath); reportPath = reportPath.substring(1); if (!reportPath.contains("solution")) { reportPath = reportPath + "&solution=steel-wheels&path=reports&name=Inventory.prpt"; //$NON-NLS-1$ } if (!reportPath.contains("path")) { reportPath = reportPath + "&path=reports"; //$NON-NLS-1$ } if (!reportPath.contains("name")) { reportPath = reportPath + "&name=Inventory.prpt"; //$NON-NLS-1$ } final String url = "http://localhost:8080/pentaho/content/reporting?" + reportPath //$NON-NLS-1$ + "&userid=joe&password=password"; //$NON-NLS-1$ System.out.println("Using development url: " + url); return url; } /* else { Window.alert("Computed-URL: " + reportPath); } */ return reportPath; }
From source file:org.pentaho.reporting.platform.plugin.gwt.client.ReportViewerUtil.java
License:Open Source License
/** * Builds the URL that is needed to communicate with the backend. * * @param renderType the render type, never null. * @param reportParameterMap the parameter map, never null. * @return the generated URL/*from w w w . j av a 2 s . c o m*/ */ public static String buildParameterUrl(final boolean paginate, final ParameterValues reportParameterMap, final ParameterDefinition parameterDefinition) { if (reportParameterMap == null) { throw new NullPointerException(); } String reportPath = Window.Location.getPath(); reportPath = reportPath.replace("viewer-gwt", "parameter"); reportPath += "?"; // NON-NLS if (reportPath.indexOf("&locale") < 0) { String localeName = StringUtils.defaultIfEmpty(Window.Location.getParameter("locale"), //$NON-NLS-1$ getLanguagePreference()); reportPath += "&locale=" + localeName; } reportParameterMap.setSelectedValue("paginate", Boolean.toString(paginate)); final ParameterValues parameters = new ParameterValues(); // User submitted values always make it into the final URL .. for (final String key : reportParameterMap.getParameterNames()) { if ("renderMode".equals(key)) { continue; } final String[] valueList = reportParameterMap.getParameterValues(key); final String[] encodedList = new String[valueList.length]; for (int i = 0; i < valueList.length; i++) { final String value = valueList[i]; if (value == null) { encodedList[i] = null; //$NON-NLS-1$ } else { encodedList[i] = value; } } parameters.setSelectedValues(key, encodedList); } // history token parameters will override default parameters (already on URL) // but they will not override user submitted parameters final ParameterValues historyParams = getHistoryTokenParameters(); if (historyParams != null) { for (final String key : historyParams.getParameterNames()) { if (parameters.containsParameter(key)) { continue; } if ("renderMode".equals(key)) { continue; } final String[] valueList = historyParams.getParameterValues(key); final String[] encodedList = new String[valueList.length]; for (int i = 0; i < valueList.length; i++) { final String value = valueList[i]; if (value == null) { encodedList[i] = null; //$NON-NLS-1$ } else { encodedList[i] = (value); } } // Window.alert("History-Value: " + key); parameters.setSelectedValues(key, encodedList); } } // Last but not least - add the paramters that were given in the URL ... // The value is decoded, the parameter name is not decoded (according to the source code for GWT-2.0). final Map<String, List<String>> requestParams = Window.Location.getParameterMap(); if (requestParams != null) { for (final String rawkey : requestParams.keySet()) { final String key = URL.decodeQueryString(rawkey); if ("renderMode".equals(key)) { continue; } if ("::session".equals(key)) { // session IDs are generated on the server, not via URL. We discard all such parameters on the URL. continue; } if (parameters.containsParameter(key)) { continue; } final List<String> valueList = requestParams.get(rawkey); final String[] encodedList = new String[valueList.size()]; for (int i = 0; i < valueList.size(); i++) { final String value = valueList.get(i); if (value == null) { encodedList[i] = null; //$NON-NLS-1$ } else { encodedList[i] = (value); } } // Window.alert("Location-Value: " + key); parameters.setSelectedValues(key, encodedList); } } final String parametersAsString = parameters.toURL(); if (History.getToken().equals(parametersAsString) == false) { // don't add duplicates, only new ones // assuming that History.getToken() returns the last newItem string unchanged, // then we must not URL-encode the paramter string. History.newItem(parametersAsString, false); } reportPath += "&" + parametersAsString; if (GWT.isScript() == false) { // Build a dev/test url System.out.println("Computed path was: " + reportPath); reportPath = reportPath.substring(1); if (!reportPath.contains("solution")) { reportPath = reportPath + "&solution=steel-wheels&path=reports&name=Inventory.prpt"; //$NON-NLS-1$ } if (!reportPath.contains("path")) { reportPath = reportPath + "&path=reports"; //$NON-NLS-1$ } if (!reportPath.contains("name")) { reportPath = reportPath + "&name=Inventory.prpt"; //$NON-NLS-1$ } final String url = "http://localhost:8080/pentaho/content/reporting?" + reportPath //$NON-NLS-1$ + "&userid=joe&password=password"; //$NON-NLS-1$ System.out.println("Using development url: " + url); return url; } /* else { Window.alert("Computed-URL: " + reportPath); } */ return reportPath; }
From source file:org.primordion.xholon.service.MeteorPlatformService.java
License:Open Source License
@Override public IXholon getService(String serviceName) { if (serviceName.equals(getXhcName())) { //consoleLog("MeteorPlatformService"); if (app == null) { app = this.getApp(); }// ww w .ja va 2s . com if (xpath == null) { xpath = this.getXPath(); } if (sessionId == null) { sessionId = makeSessionId(); } if (xholonHelperService == null) { xholonHelperService = (XholonHelperService) app.getService(IXholonService.XHSRV_XHOLON_HELPER); } if (appName == null) { appName = Location.getParameter("app"); if (appName != null) { // convert "+" back to " ", etc. appName = URL.decodeQueryString(appName); } } //createMongoCollection(this.getCollName()); // I probably don't want to do this explicitly on the client return this; } return null; }
From source file:org.rest.client.request.RequestPayloadParser.java
License:Apache License
public static ArrayList<FormPayloadData> stringToFormArrayListBoundary(String input, boolean decode) { ArrayList<FormPayloadData> result = new ArrayList<FormPayloadData>(); if (input == null || input.isEmpty()) { return result; }// w w w .java2 s.com String[] body = input.split("\n"); int lines = body.length; if (lines == 0) { return result; } FormPayloadData current = null; String currentValue = ""; for (int i = 0; i < lines; i++) { String line = body[i]; if (line.startsWith("--")) { if (current != null) { current.setValue(currentValue); result.add(current); current = new FormPayloadData(); currentValue = ""; } if (line.endsWith("--")) { //end of body break; } //begin part of body //just move to the next line } else if (line.toLowerCase().contains("content-disposition")) { String fieldName = extractNameFromBoundaryLine(line); if (decode) { fieldName = URL.decodeQueryString(fieldName.trim()); } if (current == null) { current = new FormPayloadData(); } current.setKey(fieldName); i++; line = body[i]; //next line should be empty, but check for misspelling if (!line.isEmpty()) { currentValue = line; } } else { if (!currentValue.isEmpty()) { currentValue += "\n"; } currentValue += line; } } return result; }
From source file:org.rest.client.request.RequestPayloadParser.java
License:Apache License
public static ArrayList<FormPayloadData> stringToFormArrayListMultipart(String input, boolean decode) { ArrayList<FormPayloadData> result = new ArrayList<FormPayloadData>(); if (input == null || input.isEmpty()) { return result; }//w ww. j av a 2s. c om /* * Chrome inspector has FormData output like: * key:value * key:value * and so on. * When copying from inspector parse data to create proper form data. * * But first check if it is not regular form data input. * * @TODO: check other inputs that contain ":" in it. */ RegExp htmlInputCheck = RegExp.compile("^([^\\=]{1,})=(.*)$", "m"); if (!htmlInputCheck.test(input)) { RegExp r = RegExp.compile("^([^\\:]{1,}):(.*)$", "gm"); input = r.replace(input, "$1=$2&"); if (input.endsWith("&")) { input = input.substring(0, input.length() - 1); } } String[] list = input.split("&"); for (String param : list) { String[] _tmp = param.split("=", 2); if (_tmp.length != 2) { continue; } try { String name = decode ? URL.decodeQueryString(_tmp[0].trim()) : _tmp[0].trim(); String value = decode ? URL.decodeQueryString(_tmp[1].trim()) : _tmp[1].trim(); FormPayloadData fpd = new FormPayloadData(); fpd.setKey(name); fpd.setValue(value); result.add(fpd); } catch (Exception e) { } } return result; }
From source file:org.rest.client.request.RequestPayloadParser.java
License:Apache License
/** * Parse raw body data to decoded entity body string for application/x-www-form-urlencoded encoding. * Old parseUrlencodedEntiti method//from ww w . j av a2s . c o m * @param data * @return */ public static String parseUrlEncodedEntity(String data) { if (data == null || data.equals("")) return ""; ArrayList<FormPayloadData> list = new ArrayList<FormPayloadData>(); String[] spl = data.split("&"); int len = spl.length; for (int i = 0; i < len; i++) { list.addAll(stringToFormArrayList(spl[i])); } String result = ""; for (FormPayloadData item : list) { String key = item.getKey(); String value = item.getValue(); if (!result.isEmpty()) { result += "&"; } if (!(key.trim().equals("") && value.trim().equals(""))) { result += URL.decodeQueryString(key.trim()); result += "="; result += URL.decodeQueryString(value.trim()); } } return result; }