Search in sources :

Example 6 with SolutionFileActionEvent

use of org.pentaho.mantle.client.events.SolutionFileActionEvent in project pentaho-platform by pentaho.

the class ShareFileCommand method performOperation.

public void performOperation() {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction(this.getClass().getName());
    if (selectedList != null && selectedList.size() == 1) {
        final RepositoryFile item = selectedList.get(0);
        // Checking if the user has access to manage permissions
        String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(item.getPath()) + "/canAccess?permissions=" + // $NON-NLS-1$ //$NON-NLS-2$
        MANAGE_ACLS;
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
        try {
            builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            builder.sendRequest(null, new RequestCallback() {

                public void onError(Request request, Throwable exception) {
                    FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, defaultTab, false);
                    dialog.showTab(defaultTab);
                    dialog.center();
                    event.setMessage(exception.getMessage());
                    EventBusUtil.EVENT_BUS.fireEvent(event);
                }

                public void onResponseReceived(Request request, Response response) {
                    FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, defaultTab, Boolean.parseBoolean(response.getText()));
                    dialog.showTab(FilePropertiesDialog.Tabs.PERMISSION);
                    dialog.center();
                    event.setMessage("Success");
                    EventBusUtil.EVENT_BUS.fireEvent(event);
                }
            });
        } catch (RequestException e) {
            FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, defaultTab, false);
            dialog.showTab(FilePropertiesDialog.Tabs.PERMISSION);
            dialog.center();
            event.setMessage(e.getMessage());
            EventBusUtil.EVENT_BUS.fireEvent(event);
        }
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) FilePropertiesDialog(org.pentaho.mantle.client.solutionbrowser.fileproperties.FilePropertiesDialog) Request(com.google.gwt.http.client.Request) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) PentahoTabPanel(org.pentaho.gwt.widgets.client.tabs.PentahoTabPanel) SolutionFileActionEvent(org.pentaho.mantle.client.events.SolutionFileActionEvent) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

SolutionFileActionEvent (org.pentaho.mantle.client.events.SolutionFileActionEvent)6 Request (com.google.gwt.http.client.Request)4 RequestBuilder (com.google.gwt.http.client.RequestBuilder)4 RequestCallback (com.google.gwt.http.client.RequestCallback)4 RequestException (com.google.gwt.http.client.RequestException)4 Response (com.google.gwt.http.client.Response)4 RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)3 HTML (com.google.gwt.user.client.ui.HTML)2 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)2 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)2 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)2 PentahoTabPanel (org.pentaho.gwt.widgets.client.tabs.PentahoTabPanel)2 FilePropertiesDialog (org.pentaho.mantle.client.solutionbrowser.fileproperties.FilePropertiesDialog)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 SolutionBrowserFile (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile)1