List of usage examples for com.google.gwt.http.client URL decodePathSegment
public static String decodePathSegment(String encodedURLComponent)
From source file:com.edgenius.wiki.gwt.client.GwtClientUtils.java
License:Open Source License
/** * @param event//from ww w .jav a2s. c o m * @return */ public static String getFormResult(SubmitCompleteEvent event) { String results = event.getResults() == null ? "" : event.getResults().trim(); Log.info("Form submit result:" + results); //Test case: Page access denied, login then redirect... //http://foo/page#/abc & 123 <kk> title //& need unescapeHTML; <> looks works in FF, but not in Safari - no 100% sure URL.decodeComponent() is required. //Anyway, this is may have bug for page title which has some special character combination. But happen rarely, so //mark it as low results = URL.decodePathSegment(results); results = EscapeUtil.unescapeHTML(results); Log.info("Form submit result after decoded:" + results); //Some browser pre tag contain style info, so just check <pre rather than <pre> if (results.toLowerCase().startsWith("<pre")) { results = results.substring(results.indexOf(">") + 1); if (results.toLowerCase().endsWith("</pre>")) results = results.substring(0, results.length() - 6); } //handle redir request if (results.startsWith(SharedConstants.FORM_RET_HEADER + SharedConstants.FORM_RET_ACCESS_DENIED_EXP)) { gotoLogin(results.substring( (SharedConstants.FORM_RET_HEADER + SharedConstants.FORM_RET_ACCESS_DENIED_EXP).length()), getLocation()); return null; } if (results.startsWith(SharedConstants.FORM_RET_HEADER + SharedConstants.FORM_RET_AUTH_EXP)) { redirectByForm(results .substring((SharedConstants.FORM_RET_HEADER + SharedConstants.FORM_RET_AUTH_EXP).length())); return null; } return results; }
From source file:com.google.gerrit.client.Dispatcher.java
License:Apache License
private static void projects(final String token) { String rest = skip(token);// www . j av a 2 s.co m int c = rest.indexOf(DASHBOARDS); if (0 <= c) { final String project = URL.decodePathSegment(rest.substring(0, c)); rest = rest.substring(c); if (matchPrefix(DASHBOARDS, rest)) { final String dashboardId = skip(rest); GerritCallback<DashboardInfo> cb = new GerritCallback<DashboardInfo>() { @Override public void onSuccess(DashboardInfo result) { if (matchPrefix("/dashboard/", result.url())) { String params = skip(result.url()).substring(1); ProjectDashboardScreen dash = new ProjectDashboardScreen(new Project.NameKey(project), params); Gerrit.display(token, dash); } } @Override public void onFailure(Throwable caught) { if ("default".equals(dashboardId) && RestApi.isNotFound(caught)) { Gerrit.display( PageLinks.toChangeQuery(PageLinks.projectQuery(new Project.NameKey(project)))); } else { super.onFailure(caught); } } }; if ("default".equals(dashboardId)) { DashboardList.getDefault(new Project.NameKey(project), cb); return; } c = dashboardId.indexOf(":"); if (0 <= c) { final String ref = URL.decodeQueryString(dashboardId.substring(0, c)); final String path = URL.decodeQueryString(dashboardId.substring(c + 1)); DashboardList.get(new Project.NameKey(project), ref + ":" + path, cb); return; } } } Gerrit.display(token, new NotFoundScreen()); }
From source file:com.google.gerrit.client.groups.GroupInfo.java
License:Apache License
public final AccountGroup.UUID getGroupUUID() { return new AccountGroup.UUID(URL.decodePathSegment(id())); }
From source file:com.google.gerrit.client.groups.GroupInfo.java
License:Apache License
public final AccountGroup.UUID getOwnerUUID() { String owner = owner_id();/*from w w w. j a v a 2 s . co m*/ if (owner != null) { return new AccountGroup.UUID(URL.decodePathSegment(owner)); } return null; }
From source file:com.googlesource.gerrit.plugins.verifystatus.client.JobsDropDownPanel.java
License:Apache License
JobsDropDownPanel(Panel panel) { ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast(); String decodedChangeId = URL.decodePathSegment(change.id()); RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast(); new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id()) .view(Plugin.get().getPluginName(), "verifications").addParameter("sort", "REPORTER") .addParameter("filter", "CURRENT").get(new AsyncCallback<NativeMap<VerificationInfo>>() { @Override/* w w w. java 2 s . co m*/ public void onSuccess(NativeMap<VerificationInfo> result) { if (!result.isEmpty()) { display(result); } } @Override public void onFailure(Throwable caught) { // never invoked } }); }
From source file:com.googlesource.gerrit.plugins.verifystatus.client.JobsPanel.java
License:Apache License
JobsPanel(Panel panel) { final ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast(); String decodedChangeId = URL.decodePathSegment(change.id()); final RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast(); new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id()) .view(Plugin.get().getPluginName(), "verifications").addParameter("sort", "REPORTER") .addParameter("filter", "CURRENT").get(new AsyncCallback<NativeMap<VerificationInfo>>() { @Override/*from w w w . j a va 2s . co m*/ public void onSuccess(NativeMap<VerificationInfo> result) { if (!result.isEmpty()) { final String patchsetId = change._number() + "/" + rev.id(); display(patchsetId, result); } } @Override public void onFailure(Throwable caught) { // never invoked } }); }
From source file:com.googlesource.gerrit.plugins.verifystatus.client.JobsSummaryPanel.java
License:Apache License
JobsSummaryPanel(Panel panel) { final ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast(); String decodedChangeId = URL.decodePathSegment(change.id()); final RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast(); new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id()) .view(Plugin.get().getPluginName(), "verifications").addParameter("sort", "REPORTER") .addParameter("filter", "CURRENT").get(new AsyncCallback<NativeMap<VerificationInfo>>() { @Override//from w ww.j a v a2 s . co m public void onSuccess(NativeMap<VerificationInfo> result) { if (!result.isEmpty()) { display(result); } } @Override public void onFailure(Throwable caught) { // never invoked } }); }
From source file:com.googlesource.gerrit.plugins.zuul.client.LabelPanel.java
License:Apache License
LabelPanel(final Panel panel) { final ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast(); final RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast(); if (!rev.isEdit()) { String decodedChangeId = URL.decodePathSegment(change.id()); new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id()) .view(Plugin.get().getPluginName(), "crd").get(new AsyncCallback<DependencyInfo>() { @Override/*ww w . j a va2 s.com*/ public void onSuccess(DependencyInfo result) { if (result != null) { display(result); } } @Override public void onFailure(Throwable caught) { // never invoked } }); } }
From source file:com.gwtplatform.common.client.ClientUrlUtils.java
License:Apache License
@Override public String decodePathSegment(String encodedPathSegment) { return URL.decodePathSegment(encodedPathSegment); }
From source file:com.vaadin.client.ui.ui.UIConnector.java
License:Apache License
@Override public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { getWidget().id = getConnectorId();//from ww w . j a va2 s .c o m boolean firstPaint = getWidget().connection == null; getWidget().connection = client; getWidget().immediate = getState().immediate; getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); // this also implicitly removes old styles String styles = ""; styles += getWidget().getStylePrimaryName() + " "; if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { styles += style + " "; } } if (!client.getConfiguration().isStandalone()) { styles += getWidget().getStylePrimaryName() + "-embedded"; } getWidget().setStyleName(styles.trim()); getWidget().makeScrollable(); clickEventHandler.handleEventHandlerRegistration(); // Process children int childIndex = 0; // Open URL:s boolean isClosed = false; // was this window closed? while (childIndex < uidl.getChildCount() && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { final UIDL open = uidl.getChildUIDL(childIndex); final String url = client.translateVaadinUri(open.getStringAttribute("src")); final String target = open.getStringAttribute("name"); if (target == null) { // source will be opened to this browser window, but we may have // to finish rendering this window in case this is a download // (and window stays open). Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { VUI.goTo(url); } }); } else if ("_self".equals(target)) { // This window is closing (for sure). Only other opens are // relevant in this change. See #3558, #2144 isClosed = true; VUI.goTo(url); } else { String options; boolean alwaysAsPopup = true; if (open.hasAttribute("popup")) { alwaysAsPopup = open.getBooleanAttribute("popup"); } if (alwaysAsPopup) { if (open.hasAttribute("border")) { if (open.getStringAttribute("border").equals("minimal")) { options = "menubar=yes,location=no,status=no"; } else { options = "menubar=no,location=no,status=no"; } } else { options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes"; } if (open.hasAttribute("width")) { int w = open.getIntAttribute("width"); options += ",width=" + w; } if (open.hasAttribute("height")) { int h = open.getIntAttribute("height"); options += ",height=" + h; } Window.open(url, target, options); } else { open(url, target); } } childIndex++; } if (isClosed) { // We're navigating away, so stop the application. client.setApplicationRunning(false); return; } // Handle other UIDL children UIDL childUidl; while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { String tag = childUidl.getTag().intern(); if (tag == "actions") { if (getWidget().actionHandler == null) { getWidget().actionHandler = new ShortcutActionHandler(getWidget().id, client); } getWidget().actionHandler.updateActionMap(childUidl); } else if (tag == "notifications") { for (final Iterator<?> it = childUidl.getChildIterator(); it.hasNext();) { final UIDL notification = (UIDL) it.next(); VNotification.showNotification(client, notification); } } else if (tag == "css-injections") { injectCSS(childUidl); } } if (uidl.hasAttribute("focused")) { // set focused component when render phase is finished Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { ComponentConnector connector = (ComponentConnector) uidl.getPaintableAttribute("focused", getConnection()); if (connector == null) { // Do not try to focus invisible components which not // present in UIDL return; } final Widget toBeFocused = connector.getWidget(); /* * Two types of Widgets can be focused, either implementing * GWT Focusable of a thinner Vaadin specific Focusable * interface. */ if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; toBeFocusedWidget.setFocus(true); } else if (toBeFocused instanceof Focusable) { ((Focusable) toBeFocused).focus(); } else { getLogger().severe("Server is trying to set focus to the widget of connector " + Util.getConnectorString(connector) + " but it is not focusable. The widget should implement either " + com.google.gwt.user.client.ui.Focusable.class.getName() + " or " + Focusable.class.getName()); } } }); } // Add window listeners on first paint, to prevent premature // variablechanges if (firstPaint) { Window.addWindowClosingHandler(getWidget()); Window.addResizeHandler(getWidget()); } if (uidl.hasAttribute("scrollTo")) { final ComponentConnector connector = (ComponentConnector) uidl.getPaintableAttribute("scrollTo", getConnection()); scrollIntoView(connector); } if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) { String location = uidl.getStringAttribute(UIConstants.LOCATION_VARIABLE); String newFragment; int fragmentIndex = location.indexOf('#'); if (fragmentIndex >= 0) { // Decode fragment to avoid double encoding (#10769) newFragment = URL.decodePathSegment(location.substring(fragmentIndex + 1)); if (newFragment.isEmpty() && Location.getHref().indexOf('#') == -1) { // Ensure there is a trailing # even though History and // Location.getHash() treat null and "" the same way. Location.assign(Location.getHref() + "#"); } } else { // No fragment in server-side location, but can't completely // remove the browser fragment since that would reload the page newFragment = ""; } getWidget().currentFragment = newFragment; if (!newFragment.equals(History.getToken())) { History.newItem(newFragment, true); } } if (firstPaint) { // Queue the initial window size to be sent with the following // request. Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { getWidget().sendClientResized(); } }); } }