List of usage examples for com.google.gwt.http.client URL encodeComponent
@Deprecated public static String encodeComponent(String decodedURLComponent)
From source file:org.gss_project.gss.web.client.FileMenu.java
License:Open Source License
public String getDownloadURL(FileResource file) { GSS app = GSS.get();/*from w w w . ja v a 2 s. c o m*/ if (file != null) { String dateString = RestCommand.getDate(); String resource = file.getUri().substring(app.getApiPath().length() - 1, file.getUri().length()); String sig = app.getCurrentUserResource().getUsername() + " " + RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken())); return file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString); } return ""; }
From source file:org.gss_project.gss.web.client.FileUploadDialog.java
License:Open Source License
/** * Same as URL.encodeComponent, but also * encode apostrophe since browsers aren't consistent about it * (FF encodes, IE does not)./*from w w w.j a v a 2s .c o m*/ */ private String encodeComponent(String decodedURLComponent) { String retv = URL.encodeComponent(decodedURLComponent); retv = retv.replaceAll("'", "%27"); return retv; }
From source file:org.gss_project.gss.web.client.FileUploadGearsDialog.java
License:Open Source License
/** * Same as URL.encode, but also encode apostrophe since browsers aren't * consistent about it (FF encodes, IE does not). *//*from ww w. j a va 2 s. c o m*/ protected String encode(String decodedURL) { String retv = decodedURL.replaceAll("@", "_"); // Replace bad character retv = URL.encodeComponent(retv); retv = retv.replaceAll("'", "%27"); return retv; }
From source file:org.gss_project.gss.web.client.FolderPropertiesDialog.java
License:Open Source License
/** * Generate an RPC request to create a new folder. * * @param userId the ID of the user whose namespace will be searched for * folders/*from w w w. j a v a2 s .com*/ * @param _folderName the name of the folder to create */ private void createFolder() { String name = folderName.getText(); if (!GSS.isValidResourceName(name)) { GSS.get().displayError("The folder name '" + name + "' is invalid"); return; } PostCommand ep = new PostCommand(folder.getUri() + "?new=" + URL.encodeComponent(name), "", 201) { @Override public void onComplete() { //TODO:CELLTREE if (folder.getUri().equals(GSS.get().getTreeView().getMyFolders().getUri())) { GSS.get().getTreeView().updateRootNode(); } else GSS.get().getTreeView() .updateNodeChildren((RestResourceWrapper) GSS.get().getTreeView().getSelection()); //GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent()); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary" + " permissions or a folder with same name " + "already exists"); else if (statusCode == 404) GSS.get().displayError("Resource not found"); else GSS.get() .displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error creating folder:" + t.getMessage()); } }; DeferredCommand.addCommand(ep); }
From source file:org.gss_project.gss.web.client.GroupPropertiesDialog.java
License:Open Source License
/** * Generate an RPC request to create a new group. * * @param userId the ID of the user whose namespace will be searched for * groups/*w w w. j a v a2 s .c om*/ * @param aGroupName the name of the group to create */ private void createGroup(String aGroupName) { if (aGroupName == null || aGroupName.length() == 0) { GSS.get().displayError("Empty group name!"); return; } GWT.log("createGroup(" + aGroupName + ")", null); PostCommand cg = new PostCommand( GSS.get().getCurrentUserResource().getGroupsPath() + "?name=" + URL.encodeComponent(aGroupName), "", 201) { @Override public void onComplete() { GSS.get().getGroups().updateGroups(); GSS.get().showUserList(); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary permissions"); else if (statusCode == 404) GSS.get().displayError("Resource does not exist"); else if (statusCode == 409) GSS.get().displayError("A group with the same name already exists"); else if (statusCode == 413) GSS.get().displayError("Your quota has been exceeded"); else GSS.get().displayError("Unable to create group:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error creating group:" + t.getMessage()); } }; DeferredCommand.addCommand(cg); }
From source file:org.gss_project.gss.web.client.SearchResults.java
License:Open Source License
@Override public void onBrowserEvent(Event event) { if (files == null || files.size() == 0) { if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { menuShowing = new FileContextMenu(images, false, true); menuShowing = menuShowing.onEmptyEvent(event); event.preventDefault();//from w w w.j ava 2s.c o m event.cancelBubble(true); } return; } if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) { GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null); menuShowing = new FileContextMenu(images, false, false); menuShowing = menuShowing.onEvent(event); event.cancelBubble(true); event.preventDefault(); } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { menuShowing = new FileContextMenu(images, false, true); menuShowing = menuShowing.onEmptyEvent(event); event.cancelBubble(true); event.preventDefault(); } else if (DOM.eventGetType(event) == Event.ONDBLCLICK) if (getSelectedFiles().size() == 1) { GSS app = GSS.get(); FileResource file = getSelectedFiles().get(0); String dateString = RestCommand.getDate(); String resource = file.getUri().substring(app.getApiPath().length() - 1, file.getUri().length()); String sig = app.getCurrentUserResource().getUsername() + " " + RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken())); if (!file.isDeleted()) { Window.open(file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString), "_blank", ""); } event.preventDefault(); return; } super.onBrowserEvent(event); }
From source file:org.gss_project.gss.web.client.VersionsList.java
License:Open Source License
public void showVersionsTable() { int i = 1;//from w w w .j av a2 s . c o m if (toRemove != null) { versions.remove(toRemove); toRemove = null; } for (final FileResource dto : versions) { HTML restoreVersion = new HTML("<a href='#' class='hidden-link info'><span>" + AbstractImagePrototype.create(images.restore()).getHTML() + "</span><div>Restore this Version</div></a>"); restoreVersion.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { restoreVersion(dto); } }); permTable.setHTML(i, 0, "<span>" + dto.getVersion() + "</span>"); permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + GSS.get().findUserFullName(dto.getCreatedBy()) + "</span>"); permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + GSS.get().findUserFullName(dto.getModifiedBy()) + "</span>"); permTable.setHTML(i, 3, "<span>" + dto.getFileSizeAsString() + "</span>"); HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>" + AbstractImagePrototype.create(images.download()).getHTML() + "</span><div>View this Version</div></a>"); downloadHtml.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { GSS app = GSS.get(); String dateString = RestCommand.getDate(); String resource = dto.getUri().substring(app.getApiPath().length() - 1, dto.getUri().length()); String sig = app.getCurrentUserResource().getUsername() + " " + RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken())); String fileUrl = dto.getUri() + "?version=" + dto.getVersion() + "&Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString); Window.open(fileUrl, "_BLANK", ""); } }); permTable.setWidget(i, 4, downloadHtml); permTable.setWidget(i, 5, restoreVersion); permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels"); permTable.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setColSpan(i, 1, 2); permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER); i++; } for (; i < permTable.getRowCount(); i++) permTable.removeRow(i); }
From source file:org.gwtcmis.rest.ProxyUtil.java
License:Open Source License
/** * @param url url//w w w . j a v a 2 s . c o m * @return {@link String} full url */ public static String getCheckedURL(String url) { String proxyServiceContext = getProxyServiceContext(); if (proxyServiceContext == null || "".equals(proxyServiceContext)) { return url; } if (!(url.startsWith("http://") || url.startsWith("https://"))) { return url; } String currentHost = getCurrentHost(); if (url.startsWith(currentHost)) { return url; } return proxyServiceContext + "?url=" + URL.encodeComponent(url); }
From source file:org.onebusaway.presentation.client.UrlBuilder.java
License:Apache License
/** * Build the URL and return it as an encoded string. * //from w w w .ja v a 2 s. c o m * @return the encoded URL string */ public String buildString() { StringBuilder url = new StringBuilder(); // http:// url.append(protocol).append("://"); // http://www.google.com if (host != null) { url.append(host); } // http://www.google.com:80 if (port != PORT_UNSPECIFIED) { url.append(":").append(port); } // http://www.google.com:80/path/to/file.html if (path != null && !"".equals(path)) { url.append("/").append(URL.encode(path)); } // Generate the query string. // http://www.google.com:80/path/to/file.html?k0=v0&k1=v1 char prefix = '?'; for (Map.Entry<String, String[]> entry : listParamMap.entrySet()) { String key = URL.encodeComponent(entry.getKey()); for (String val : entry.getValue()) { url.append(prefix).append(key).append('='); if (val != null) { url.append(URL.encodeComponent(val)); } prefix = '&'; } } // http://www.google.com:80/path/to/file.html?k0=v0&k1=v1#token if (hash != null) { url.append("#").append(hash); } return url.toString(); }
From source file:org.pentaho.mantle.client.commands.AnalysisViewCommand.java
License:Open Source License
protected void performOperation(boolean feedback) { final SolutionBrowserPerspective navigatorPerspective = SolutionBrowserPerspective.getInstance(); final AnalysisViewDialog analysisDialog = new AnalysisViewDialog(); IDialogCallback callback = new IDialogCallback() { public void cancelPressed() { }/*from ww w. j a v a 2s . c o m*/ public void okPressed() { // without the timer, this code would cause a crash in IE6 and IE7 Timer timer = new Timer() { @Override public void run() { String actionName = System.currentTimeMillis() + ".analysisview.xaction"; //$NON-NLS-1$ String newAnalysisViewURL = "AnalysisViewService?component=createNewView&name=" + //$NON-NLS-1$ URL.encodeComponent(actionName) + "&descr=" + //$NON-NLS-1$ URL.encodeComponent(actionName) + "&actionName=" + //$NON-NLS-1$ URL.encodeComponent(actionName) + "&textfield=&schema=" + //$NON-NLS-1$ URL.encodeComponent(analysisDialog.getSchema()) + "&cube=" + //$NON-NLS-1$ URL.encodeComponent(analysisDialog.getCube()) + "&solution=system&actionPath=tmp"; //$NON-NLS-1$ if (!GWT.isScript()) { newAnalysisViewURL = "http://localhost:8080/pentaho/" + newAnalysisViewURL //$NON-NLS-1$ + "&userid=joe&password=password"; //$NON-NLS-1$ } navigatorPerspective.getContentTabPanel().showNewURLTab( Messages.getString("newAnalysisView"), Messages.getString("newAnalysisView"), //$NON-NLS-1$//$NON-NLS-2$ newAnalysisViewURL, false); // Set it to save-enabled and fire event navigatorPerspective.getContentTabPanel().getCurrentFrame().setSaveEnabled(true); navigatorPerspective.fireSolutionBrowserListenerEvent( SolutionBrowserListener.EventType.OPEN, navigatorPerspective.getContentTabPanel().getSelectedTabIndex()); // navigatorPerspective.refreshPerspective(false); } }; timer.schedule(1); } }; IDialogValidatorCallback validatorCallback = new IDialogValidatorCallback() { public boolean validate() { return analysisDialog.validate(); } }; analysisDialog.setValidatorCallback(validatorCallback); analysisDialog.setCallback(callback); analysisDialog.center(); }