Example usage for com.google.gwt.http.client URL encodeQueryString

List of usage examples for com.google.gwt.http.client URL encodeQueryString

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encodeQueryString.

Prototype

public static String encodeQueryString(String decodedURLComponent) 

Source Link

Document

Returns a string where all characters that are not valid for a URL component have been escaped.

Usage

From source file:org.bonitasoft.forms.client.view.widget.UserLogoutWidget.java

License:Open Source License

/**
 * Build the widget/*  w  w  w  . j a v  a 2 s. c  o m*/
 * @param user the logged in user
 * @return the {@link Widget}
 */
protected Widget buildUserIdentityCard() {

    final FlowPanel theIDWidget = new FlowPanel();
    theIDWidget.setStylePrimaryName("bonita_identification");

    final FlowPanel theLeftAlignedBox = new FlowPanel();
    theLeftAlignedBox.setStylePrimaryName("bonita_identified-left");

    theIDWidget.add(theLeftAlignedBox);

    final Image theAvatar = new Image("images/avatar-default.gif");
    theAvatar.setStyleName("bonita_avatar");

    theLeftAlignedBox.add(theAvatar);

    final FlowPanel theRightAlignedBox = new FlowPanel();
    theRightAlignedBox.setStylePrimaryName("bonita_identified-right");

    theLeftAlignedBox.add(theRightAlignedBox);

    HTML theUserIdentity = null;
    if (user.isAnonymous()) {
        theUserIdentity = new HTML(FormsResourceBundle.getMessages().anonymousLabel());
    } else {
        theUserIdentity = new HTML(user.getUsername());
    }
    theUserIdentity.setStylePrimaryName("bonita_identif-1");

    theRightAlignedBox.add(theUserIdentity);

    Anchor theLogoutLink = null;
    if (user.isAnonymous()) {
        theLogoutLink = new Anchor(FormsResourceBundle.getMessages().loginButtonLabel());
    } else {
        theLogoutLink = new Anchor(FormsResourceBundle.getMessages().logoutButtonLabel());
    }
    theLogoutLink.setStylePrimaryName("bonita_identif-2");

    final URLUtils urlUtils = URLUtilsFactory.getInstance();
    final List<String> paramsToRemove = new ArrayList<String>();
    paramsToRemove.add(URLUtils.LOCALE_PARAM);
    final List<String> hashParamsToRemove = new ArrayList<String>();
    if (user.isAutoLogin()) {
        hashParamsToRemove.add(URLUtils.AUTO_LOGIN_PARAM);
    } else {
        hashParamsToRemove.add(URLUtils.USER_CREDENTIALS_PARAM);
    }
    if (!user.isAnonymous()) {
        for (final Entry<String, Object> hashParamEntry : context.entrySet()) {
            hashParamsToRemove.add(hashParamEntry.getKey());
        }
    }
    Map<String, String> hashParamsToAdd = new HashMap<String, String>();
    hashParamsToAdd.put(URLUtils.TODOLIST_PARAM, "true");
    hashParamsToAdd.put(URLUtils.VIEW_MODE_PARAM, "app");
    final String theRedirectURL = urlUtils.rebuildUrl(paramsToRemove, null, hashParamsToRemove,
            hashParamsToAdd);
    String theURL = "?" + URLUtils.REDIRECT_URL_PARAM + "=";
    try {
        theURL += URL.encodeQueryString(theRedirectURL);
    } catch (final Exception e) {
        Window.alert("Unable to redirect to login page: Invalid URL");
        theURL += GWT.getModuleBaseURL();
    }
    theLogoutLink.setHref(theURL);

    theRightAlignedBox.add(theLogoutLink);

    return theIDWidget;
}

From source file:org.bonitasoft.web.toolkit.client.common.url.UrlUtil.java

License:Open Source License

public static String escape(final String string) {
    return URL.encodeQueryString(string);
}

From source file:org.cloudcoder.app.client.view.PythonTutorView.java

License:Open Source License

/**
 * Constructor.//from  w  ww  .j  av  a 2  s . c  om
 * 
 * @param code                the student's Python code
 * @param problem             the {@link Problem}
 * @param nonSecretTestCases  the non-secret {@link TestCase}s for the problem
 * @param width               the width of the visualizer iframe, in pixels
 * @param height              the height of the visualizer iframe, in pixels
 */
public PythonTutorView(String code, Problem problem, TestCase[] nonSecretTestCases, int width, int height) {
    this.code = code;
    this.problem = problem;
    this.nonSecretTestCases = nonSecretTestCases;

    // Generate "scaffolded" code with all of the non-secret test cases
    String scaffoldedCode = getScaffoldedCode();
    String encodedScaffoldedCode = URL.encodeQueryString(scaffoldedCode);

    // See: https://github.com/pgbovine/OnlinePythonTutor/blob/master/v3/docs/embedding-HOWTO.md
    HTML iframe = new HTML("<iframe width=\"" + width + "\" height=\"" + height + "\" frameborder=\"0\""
            + " src=\"http://pythontutor.com/iframe-embed.html#code=" + encodedScaffoldedCode
            + "&py=2\"></iframe>");
    initWidget(iframe);
}

From source file:org.datacleaner.monitor.scheduling.widgets.SchedulePanel.java

License:Open Source License

public SchedulePanel(final ClientConfig clientConfig, final ScheduleDefinition schedule,
        final SchedulingServiceAsync service) {
    super();/*from w w  w. j a v a  2  s.c  o  m*/

    _clientConfig = clientConfig;
    _schedule = schedule;

    initWidget(uiBinder.createAndBindUi(this));

    // add the job type as a style name
    final String jobType = schedule.getJob().getType();
    if (jobType != null) {
        addStyleName(jobType);
    }

    updateScheduleWidgets();

    final TenantIdentifier tenant = _clientConfig.getTenant();

    final String encodedJobName = URL.encodeQueryString(schedule.getJob().getName());

    if (_clientConfig.isJobEditor()) {
        moreButton
                .addClickHandler(new CustomizeJobClickHandler(this, tenant, schedule, service, _clientConfig));
    }

    if (_clientConfig.isScheduleEditor()) {
        CustomizeScheduleClickHandler handler = new CustomizeScheduleClickHandler(this, service, tenant,
                schedule);
        scheduleAnchor.addClickHandler(handler);

        final String token = History.getToken();
        GWT.log("Encoded job name: " + encodedJobName);
        if (("schedule_" + encodedJobName).equals(token)) {
            History.newItem("");
            handler.showSchedulingPopup();
        }
    }

    if (!_clientConfig.isJobEditor()) {
        alertsPanel.setVisible(false);
    }

    if (_clientConfig.isScheduleEditor()) {
        TriggerJobClickHandler handler = new TriggerJobClickHandler(service, tenant, schedule);
        executeButton.addClickHandler(handler);

        final String token = History.getToken();
        if (("trigger_" + encodedJobName).equals(token)) {
            History.newItem("");
            handler.showExecutionPopup();
        }
    }

    final List<AlertDefinition> alerts = schedule.getAlerts();
    if (alerts.size() > 0) {

        final Anchor expandAlertsAnchor = new Anchor(alerts.size() + " alert(s)");
        if (alerts.isEmpty()) {
            expandAlertsAnchor.addStyleName("discrete");
        }

        expandAlertsAnchor.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                final FlowPanel alertListPanel = new FlowPanel();
                alertListPanel.setStyleName("AlertListPanel");

                for (AlertDefinition alert : alerts) {
                    AlertPanel alertPanel = new AlertPanel(service, schedule, alert);
                    alertListPanel.add(alertPanel);
                }

                alertsPanel.clear();
                alertsPanel.add(alertListPanel);
            }
        });
        alertsPanel.add(expandAlertsAnchor);
    }
}

From source file:org.datacleaner.monitor.wizard.DatastoreWizardController.java

License:Open Source License

@Override
protected void wizardFinished(final String datastoreName) {
    final String encodedDatastoreName = URL.encodeQueryString(datastoreName);

    final Button button = DCButtons.primaryButton(null, "Close");
    button.addClickHandler(new ClickHandler() {
        @Override/* w  ww. j  a v  a 2s . com*/
        public void onClick(ClickEvent event) {
            // full page refresh.
            closeWizardAfterFinishing(datastoreName, "datastores");
        }
    });

    final Anchor jobWizardAnchor = new Anchor("Build a job for this datastore");
    jobWizardAnchor.addStyleName("BuildJob");
    jobWizardAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String htmlDivId = getWizardPanel().getCustomHtmlDivId();
            closeWizardAfterFinishing(datastoreName, null);

            JavaScriptCallbacks.startJobWizard(datastoreName, null, htmlDivId);
        }
    });

    final Anchor queryAnchor = new Anchor("Explore / query this datastore");
    queryAnchor.addStyleName("QueryDatastore");
    queryAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = Urls.createRelativeUrl("query?ds=" + encodedDatastoreName);
            Window.open(url, "_blank", "location=no,width=770,height=400,toolbar=no,menubar=no");
        }
    });

    final FlowPanel contentPanel = new FlowPanel();
    contentPanel.addStyleName("WizardFinishedPanel");
    contentPanel.add(new Label("Datastore '" + datastoreName + "' created! Wizard finished."));

    contentPanel.add(new Label(
            "Click 'Close' to return, or click one of the links below to start using the datastore."));
    contentPanel.add(jobWizardAnchor);
    contentPanel.add(queryAnchor);

    setContent(contentPanel);
    getWizardPanel().getButtonPanel().clear();
    getWizardPanel().getButtonPanel().addButton(button);
    getWizardPanel().refreshUI();
}

From source file:org.dataconservancy.dcs.access.client.presenter.AcrDataPresenter.java

License:Apache License

void addGetPubHandler() {

    ir.addChangeHandler(new ChangeHandler() {
        @Override/*from www.  j  a  v a 2  s  .c om*/
        public void onChange(ChangeEvent event) {
            ROList.clear();
            final StatusPopupPanel mediciWait = new StatusPopupPanel("Retrieving", "wait", false);
            mediciWait.show();
            existingFileSets = new HashMap<String, FileTable>();
            previousSelectedFiles = new HashMap<String, List<FileNode>>();
            int selected = ir.getSelectedIndex();

            final String instance = ir.getValue(selected);

            mediciService.getAcrInstances(new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {

                    for (MediciInstance ins : result)
                        if (ins.getTitle().equalsIgnoreCase(instance))
                            sparqlEndpoint = ins;

                    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
                            SeadApp.ACRCOMMON + "?instance=" + URL.encodeQueryString(sparqlEndpoint.getTitle())
                                    + "&" + "query="
                                    + URL.encodeQueryString(Query.PROPOSED_FOR_PUBLICATION.getTitle()));

                    rb.setHeader("Content-type", "application/x-www-form-urlencoded");

                    try {
                        Request response = rb.sendRequest(null, new RequestCallback() {
                            @Override
                            public void onError(Request request, Throwable exception) {
                                Window.alert("Failed");
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                String json = response.getText();
                                mediciService.parseJson(json, new AsyncCallback<Map<String, String>>() {

                                    @Override
                                    public void onSuccess(Map<String, String> result) {

                                        //   leftPanel.clear();
                                        JsonpRequestBuilder rb = new JsonpRequestBuilder();
                                        rb.setTimeout(100000);

                                        mediciWait.hide();
                                        last = result.size() - 1;
                                        final FlexTable grid = new FlexTable();
                                        grid.setWidth("100%");
                                        grid.setHeight("100%");

                                        final Iterator it = result.entrySet().iterator();
                                        while (it.hasNext()) {
                                            final Map.Entry pair = (Map.Entry) it.next();
                                            final String dName = (String) pair.getValue();

                                            flagHyperlink = 0;
                                            String tagRetrieveUrl = SeadApp.accessurl + SeadApp.queryPath
                                                    + "?q=resourceValue:" + "(" + URL.encodeQueryString(
                                                            ((String) pair.getKey()).replace(":", "\\:"))
                                                    + ")";
                                            rb.requestObject(tagRetrieveUrl,
                                                    new AsyncCallback<JsSearchResult>() {

                                                        public void onFailure(Throwable caught) {
                                                            Util.reportInternalError(
                                                                    "Matching collection in VA failed", caught);

                                                        }

                                                        public void onSuccess(JsSearchResult result) {
                                                            //                                          if(result.matches().length()==0||sparqlEndpoint.equals("http://sead.ncsa.illinois.edu/acr/resteasy/sparql"))
                                                            //                                          {
                                                            dataset = Util.label(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    "Hyperlink");
                                                            flagHyperlink = 1;
                                                            ROList.addItem(dName
                                                                    .substring(dName.lastIndexOf("/") + 1));
                                                            //                                          }                           
                                                            //                                          else
                                                            //                                              flagHyperlink =0;

                                                            /*          if(flagHyperlink==1){
                                                              dataset.addClickHandler(new ClickHandler() {
                                                                  @Override
                                                                  public void onClick(ClickEvent event) {
                                                                      mediciService.restartIngest((String)pair.getKey(), SeadApp.tmpHome, new AsyncCallback<CheckPointDetail>(){
                                                                    
                                                                          @Override
                                                                          public void onFailure(
                                                                                  Throwable caught) {
                                                                              Window.alert("Error in estimating reingest scenario. \n" + caught.getMessage());
                                                                          }
                                                                    
                                                                          @Override
                                                                          public void onSuccess(
                                                                                  final CheckPointDetail result) {
                                                                              if(!result.isCheckPointed()){
                                                                                  final StatusPopupPanel collectionWait = new StatusPopupPanel("Querying for BagIt Bag","bag",false);
                                                                                  collectionWait.show();
                                                                    
                                                                                          final MultiSelectionModel<CollectionNode> selectionModel = new MultiSelectionModel<CollectionNode>();
                                                                    
                                                                                          mediciService.getBag(
                                                                                                  (String) pair.getKey(), sparqlEndpoint,
                                                                                                  SeadApp.bagIturl, SeadApp.tmpHome,
                                                                                                   new AsyncCallback<String>() {
                                                                                                      @Override
                                                                                                      public void onSuccess(final String bagPath) {
                                                                                                          collectionWait.setValue("Converting to SEAD SIP", "wait");
                                                                    
                                                                                                          final Timer getSIPTimer = new Timer() {
                                                                    
                                                                                                          @Override
                                                                                                          public void run() {
                                                                                                              String tempguid = null;
                                                                                                              if(((String) pair.getKey()).contains("/"))
                                                                                                                  tempguid = ((String) pair.getKey()).split("/")
                                                                                                                  [((String) pair.getKey()).split("/").length-1];
                                                                                                              else
                                                                                                                  tempguid = ((String) pair.getKey()).split(":")
                                                                                                                  [((String) pair.getKey()).split(":").length-1];
                                                                                                              final String guid = tempguid;
                                                                                                              mediciService.getSipFromBag(
                                                                                                                      bagPath,
                                                                                                                  SeadApp.tmpHome+guid+"_sip.xml",
                                                                                                                  SeadApp.bagIturl,
                                                                                                                  new AsyncCallback<String>() {
                                                                    
                                                                                                              @Override
                                                                                                              public void onSuccess(String result) {
                                                                    
                                                                                                                  mediciService.getFileNos(new AsyncCallback<Integer>(){
                                                                                                                      @Override
                                                                                                                      public void onFailure(
                                                                                                                              Throwable caught) {
                                                                                                                          Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                                      }
                                                                    
                                                                                                                      @Override
                                                                                                                      public void onSuccess(Integer size) {
                                                                                                                          if(size>Constants.MAX){
                                                                                                                              Window.alert("This collection has more than "+Constants.MAX+" files.\n"+
                                                                                                                                           "Hence preview is not possible. But you can start the ingest");
                                                                                                                              if(collectionWait.isShowing())
                                                                                                                                  collectionWait.hide();
                                                                                                                              getPub.setEnabled(false);
                                                                                                                              cloudCopy.setEnabled(true);
                                                                                                                              mdCb.setEnabled(true);
                                                                                                                              ingestButton.setEnabled(true);
                                                                                                                              ir.setEnabled(false);
                                                                                                                              ir.setStyleName("greyFont");
                                                                                                                              getPub.setStyleName("greyFont");
                                                                                                                              cloudCopy.setStyleName("greenFont");
                                                                                                                              mdCb.setStyleName("greenFont");
                                                                                                                              ingestButton.setStyleName("greenFont");
                                                                    
                                                                    
                                                                                                                              ingestButton.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                  @Override
                                                                                                                                  public void onClick(ClickEvent event) {
                                                                                                                                      ingestButton.setEnabled(false);
                                                                                                                                      cloudCopy.setEnabled(false);
                                                                                                                                      ir.setEnabled(false);
                                                                                                                                      getPub.setEnabled(true);
                                                                                                                                      String rootMediciId= (String) pair.getKey();
                                                                    
                                                                    
                                                                                                                                      AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                              @Override
                                                                                                                                              public void onSuccess(Void result) {
                                                                                                                                                  mediciService.addMetadata(metadataSrc,SeadApp.tmpHome+guid+"_sip", new AsyncCallback<Void>() {
                                                                    
                                                                                                                                                      @Override
                                                                                                                                                      public void onSuccess(Void result) {
                                                                    
                                                                    
                                                                                                                                                          mediciService.splitSip(
                                                                                                                                                                  SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                  new AsyncCallback<Integer>() {
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onSuccess(Integer result) {
                                                                                                                                                                  n=result;
                                                                                                                                                                  l++;
                                                                                                                                                                  if(l<=n){
                                                                                                                                                                      mediciService.generateWfInstanceId(new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                          @Override
                                                                                                                                                                          public void onSuccess(final String wfInstanceId) {
                                                                                                                                                                              UserServiceAsync user =
                                                                                                                                                                                      GWT.create(UserService.class);
                                                                                                                                                                              user.checkSession(null,new AsyncCallback<UserSession>() {
                                                                    
                                                                                                                                                                                  @Override
                                                                                                                                                                                  public void onFailure(
                                                                                                                                                                                          Throwable caught) {
                                                                                                                                                                                      // TODO Auto-generated method stub
                                                                    
                                                                                                                                                                                  }
                                                                    
                                                                                                                                                                                  @Override
                                                                                                                                                                                  public void onSuccess(
                                                                                                                                                                                          UserSession result) {
                                                                    
                                                                                                                                                                                      mediciService.submitMultipleSips(SeadApp.deposit_endpoint + "sip",
                                                                                                                                                                                              (String) pair.getKey(),
                                                                                                                                                                                              sparqlEndpoint,
                                                                                                                                                                                              SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                                              wfInstanceId,
                                                                                                                                                                                              null,
                                                                                                                                                                                              l, n, "", "", false, GWT.getModuleBaseURL(),SeadApp.tmpHome,
                                                                                                                                                                                              new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                                                  @Override
                                                                                                                                                                                                  public void onSuccess(final String result) {
                                                                                                                                                                                                      l=-1;
                                                                                                                                                                                                      final Label notify = Util.label("!", "Notification");
                                                                                                                                                                                                      notify.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                                                                                          @Override
                                                                                                                                                                                                          public void onClick(ClickEvent event) {
                                                                                                                                                                                                              StatusPopupPanel mediciWait = new StatusPopupPanel("Retrieving","done",false);
                                                                                                                                                                                                              MessagePopupPanel popUpPanel = new MessagePopupPanel(result, "done", true);
                                                                                                                                                                                                              popUpPanel.show();
                                                                                                                                                                                                              nPanel.remove(notify);
                                                                                                                                                                                                          }
                                                                                                                                                                                                      });
                                                                                                                                                                                                      nPanel.add(notify);
                                                                                                                                                                                                  }
                                                                    
                                                                                                                                                                                                  @Override
                                                                                                                                                                                                  public void onFailure(Throwable caught) {
                                                                                                                                                                                                      Window.alert("Workflow failed.");
                                                                                                                                                                                                  }
                                                                                                                                                                                              });
                                                                    
                                                                                                                                                                                  }
                                                                    
                                                                                                                                                                              });
                                                                                                                                                                          }
                                                                    
                                                                                                                                                                          @Override
                                                                                                                                                                          public void onFailure(
                                                                                                                                                                                  Throwable caught) {
                                                                                                                                                                              // TODO Auto-generated method stub
                                                                    
                                                                                                                                                                          }
                                                                                                                                                                      });
                                                                    
                                                                                                                                                                  }
                                                                                                                                                                  else{
                                                                                                                                                                      Window.alert("This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow");
                                                                                                                                                                  }
                                                                                                                                                              }
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                                                                                                                  // TODO Auto-generated method stub
                                                                    
                                                                                                                                                              }
                                                                                                                                                          });
                                                                                                                                                      }
                                                                    
                                                                                                                                                      @Override
                                                                                                                                                      public void onFailure(Throwable caught) {
                                                                                                                                                          // TODO Auto-generated method stub
                                                                    
                                                                                                                                                      }
                                                                                                                                                  });
                                                                                                                                              }
                                                                    
                                                                                                                                          @Override
                                                                                                                                          public void onFailure(Throwable caught) {
                                                                                                                                              // TODO Auto-generated method stub
                                                                    
                                                                                                                                          }
                                                                                                                                      };
                                                                                                                                      mediciService.toVAmodel(rootMediciId,rootMediciId,sparqlEndpoint, SeadApp.tmpHome, vaModelCb );
                                                                    
                                                                                                                                  }
                                                                                                                              });
                                                                    
                                                                                                                              coverRightPanel.setVisible(true);
                                                                                                                          }
                                                                                                                          else{
                                                                                                                              mediciService.getRelations(new AsyncCallback<DatasetRelation>(){
                                                                    
                                                                    
                                                                    
                                                                                                                                  @Override
                                                                                                                                  public void onFailure(
                                                                                                                                          Throwable caught) {
                                                                                                                                      Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                                                  }
                                                                    
                                                                                                                                  @Override
                                                                                                                                  public void onSuccess(
                                                                                                                                          final DatasetRelation relations) {
                                                                    
                                                                    
                                                                    
                                                                                                                                      display.getDatasetLbl().setText("Browse Collection and sub-Collections");
                                                                                                                                      display.getFileLbl().setText("Browse Files");
                                                                                                                                          TreeViewModel model =
                                                                                                                                                  new CollectionTreeViewModel(selectionModel, relations, (String) pair.getKey());
                                                                                                                                          CellTree.Resources resource = GWT.create(TreeResources.class);
                                                                                                                                          CellTree tree = new CellTree(model, null,resource);
                                                                                                                                          //collection select
                                                                                                                                          CollectionSelectEvent.register(EVENT_BUS, new CollectionSelectEvent.Handler() {
                                                                                                                                                 public void onMessageReceived(final CollectionSelectEvent event) {
                                                                    
                                                                                                                                                      rightPanel.clear();
                                                                                                                                                      rightPanel.add(getFiles(relations.getDuAttrMap(), relations.getFileAttrMap(), event.getCollection().getId(),event.getValue()));
                                                                                                                                                 }
                                                                                                                                          });
                                                                    
                                                                                                                                          //collection click
                                                                                                                                          CollectionClickEvent.register(EVENT_BUS, new CollectionClickEvent.Handler() {
                                                                                                                                                 public void onMessageReceived(final CollectionClickEvent event) {
                                                                    
                                                                                                                                                     if(existingFileSets.containsKey(event.getCollection().getId())){
                                                                                                                                                          rightPanel.clear();
                                                                                                                                                          rightPanel.add(existingFileSets.get(event.getCollection().getId()).cellTable);
                                                                                                                                                      }
                                                                                                                                                      else{
                                                                    
                                                                                                                                                          rightPanel.clear();
                                                                                                                                                          rightPanel.add(getFiles(relations.getDuAttrMap(), relations.getFileAttrMap(), event.getCollection().getId(),false));
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                              });
                                                                                                                                          //collection passive click
                                                                                                                                          CollectionPassiveSelectEvent.register(EVENT_BUS, new CollectionPassiveSelectEvent.Handler() {
                                                                                                                                                 public void onMessageReceived(final CollectionPassiveSelectEvent event) {
                                                                    
                                                                                                                                                     CellTable files ;
                                                                                                                                                     if(existingFileSets.containsKey(event.getCollection().getId())){
                                                                                                                                                         files = existingFileSets.get(event.getCollection().getId()).cellTable;
                                                                                                                                                         for(String file:relations.getDuAttrMap().get(event.getCollection().getId()).getSub().get(SubType.File)){
                                                                                                                                                             files.getSelectionModel().setSelected((FileNode)relations.getFileAttrMap().get(file),event.getValue());
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                     else{
                                                                                                                                                         files = (CellTable) getFiles(relations.getDuAttrMap(), relations.getFileAttrMap(), event.getCollection().getId(),event.getValue());
                                                                                                                                                     }
                                                                    
                                                                                                                                                 }
                                                                                                                                              });
                                                                    
                                                                                                                                          collectionWait.hide();
                                                                                                                                          leftPanel.clear();
                                                                                                                                          leftPanel.add(tree);
                                                                    
                                                                                                                                      if(collectionWait.isShowing())
                                                                                                                                          collectionWait.hide();
                                                                                                                                      getPub.setEnabled(false);
                                                                                                                                      cloudCopy.setEnabled(true);
                                                                                                                                      mdCb.setEnabled(true);
                                                                                                                                      ingestButton.setEnabled(true);
                                                                                                                                      ir.setEnabled(false);
                                                                                                                                      ir.setStyleName("greyFont");
                                                                                                                                      getPub.setStyleName("greyFont");
                                                                                                                                      cloudCopy.setStyleName("greenFont");
                                                                                                                                      mdCb.setStyleName("greenFont");
                                                                                                                                      ingestButton.setStyleName("greenFont");
                                                                    
                                                                                                                                      ingestButton.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                          @Override
                                                                                                                                          public void onClick(ClickEvent event) {
                                                                                                                                              ingestButton.setEnabled(false);
                                                                                                                                              cloudCopy.setEnabled(false);
                                                                                                                                              ir.setEnabled(false);
                                                                                                                                              getPub.setEnabled(true);
                                                                                                                                              String rootMediciId= (String) pair.getKey();
                                                                                                                                              CollectionNode root = relations.getDuAttrMap().get(rootMediciId);
                                                                    
                                                                    
                                                                                                                                              AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                                      @Override
                                                                                                                                                      public void onSuccess(Void result) {
                                                                                                                                                          mediciService.addMetadata(metadataSrc, SeadApp.tmpHome+guid+"_sip",new AsyncCallback<Void>() {
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onSuccess(Void result) {
                                                                                                                                                                  String tempguid = null;
                                                                                                                                                                  if(((String) pair.getKey()).contains("/"))
                                                                                                                                                                      tempguid = ((String) pair.getKey()).split("/")
                                                                                                                                                                      [((String) pair.getKey()).split("/").length-1];
                                                                                                                                                                  else
                                                                                                                                                                      tempguid = ((String) pair.getKey()).split(":")
                                                                                                                                                                      [((String) pair.getKey()).split(":").length-1];
                                                                                                                                                                  final String guid = tempguid;
                                                                    
                                                                                                                                                                  mediciService.splitSip(
                                                                                                                                                                          SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                          new AsyncCallback<Integer>() {
                                                                    
                                                                                                                                                                      @Override
                                                                                                                                                                      public void onSuccess(Integer result) {
                                                                                                                                                                          n=result;
                                                                                                                                                                          l++;
                                                                    
                                                            //                                                                                                                     Window.alert("Starting ingest of dataset");//. We already have the cached SIP for this dataset.");
                                                                                                                                                                          mediciService.generateWfInstanceId(new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                              @Override
                                                                                                                                                                              public void onSuccess(String wfInstanceId) {
                                                                                                                                                                                  //Open a status panel that self queries the database for changes
                                                                                                                                                                                  WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(submitterId, wfInstanceId);
                                                                                                                                                                                  eventRefresher.show();
                                                                                                                                                                                  mediciService.submitMultipleSips(SeadApp.deposit_endpoint + "sip",
                                                                                                                                                                                          (String)pair.getKey(),
                                                                                                                                                                                          sparqlEndpoint,
                                                                                                                                                                                          SeadApp.tmpHome+guid+"_sip",
                                                                                                                                                                                          wfInstanceId,
                                                                                                                                                                                          null,
                                                                                                                                                                                          l, n, "", "", false, GWT.getModuleBaseURL(),SeadApp.tmpHome,
                                                                                                                                                                                          new AsyncCallback<String>() {
                                                                    
                                                                                                                                                                                              @Override
                                                                                                                                                                                              public void onSuccess(final String result) {
                                                                                                                                                                                                  l=-1;
                                                                                                                                                                                                  final Label notify = Util.label("!", "Notification");
                                                                                                                                                                                                  notify.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                                                                                                      @Override
                                                                                                                                                                                                      public void onClick(ClickEvent event) {
                                                                                                                                                                                                          MessagePopupPanel popUpPanel = new MessagePopupPanel(result, "done", true);
                                                                                                                                                                                                          popUpPanel.show();
                                                                                                                                                                                                          nPanel.remove(notify);
                                                                                                                                                                                                      }
                                                                                                                                                                                                  });
                                                            //                                                                                                                                       nPanel.add(notify);
                                                                                                                                                                                              }
                                                                    
                                                                                                                                                                                              @Override
                                                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                    
                                                                                                                                                                                              }
                                                                                                                                                                                          });
                                                                    
                                                                                                                                                                              }
                                                                    
                                                                                                                                                                              @Override
                                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                    
                                                                                                                                                                              }
                                                                                                                                                                          });
                                                                    
                                                                                                                                                                      }
                                                                    
                                                                                                                                                                      @Override
                                                                                                                                                                      public void onFailure(Throwable caught) {
                                                                                                                                                                          Window.alert("Failed. \n"+caught.getMessage());
                                                                                                                                                                      }
                                                                                                                                                                  });
                                                                                                                                                              }
                                                                    
                                                                                                                                                              @Override
                                                                                                                                                              public void onFailure(Throwable caught) {
                                                                                                                                                                  Window.alert("Failed. \n"+caught.getMessage());
                                                                                                                                                              }
                                                                                                                                                          });
                                                                                                                                                      }
                                                                    
                                                                                                                                                  @Override
                                                                                                                                                  public void onFailure(Throwable caught) {
                                                                                                                                                      Window.alert("Failed. \n"+caught.getMessage());
                                                                                                                                                  }
                                                                                                                                              };
                                                                                                                                              mediciService.toVAmodel(rootMediciId,rootMediciId, sparqlEndpoint, SeadApp.tmpHome, vaModelCb );
                                                                    
                                                                                                                                          }
                                                                                                                                      });
                                                                                                                                      coverRightPanel.setVisible(true);
                                                                                                                                  }
                                                                                                                              });
                                                                                                                          }
                                                                                                                      }
                                                                                                                  });
                                                                                                              }
                                                                    
                                                                                                              @Override
                                                                                                              public void onFailure(Throwable caught) {
                                                                                                                  Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                              }
                                                                                                          });
                                                                    
                                                                                                      }
                                                                                                  };
                                                                                                  getSIPTimer.schedule(5000);
                                                                                                      }
                                                                    
                                                                                                      @Override
                                                                                                      public void onFailure(Throwable caught) {
                                                                                                          Window.alert("Failed:"+caught.getMessage());
                                                                    
                                                                                                      }
                                                                                                  });
                                                                    
                                                                              }
                                                                              else{
                                                                                  //restart ingest
                                                                    
                                                                                  n=result.getNumSplitSIPs();
                                                                                  String[] arr = result.getResumeSipPath().split("_");
                                                                                  int sipNumber = Integer.parseInt(arr[arr.length-1].split("\\.")[0]);
                                                                                  l = sipNumber;
                                                                                  if(l<=n){
                                                                    
                                                                                      Window.alert("Starting reingest of dataset. We already have the cached SIP for this dataset.");
                                                                                      mediciService.generateWfInstanceId(new AsyncCallback<String>() {
                                                                    
                                                                                          @Override
                                                                                          public void onSuccess(String wfInstanceId) {
                                                                                              mediciService.submitMultipleSips(SeadApp.deposit_endpoint + "sip",
                                                                                                      null,
                                                                                                      sparqlEndpoint,
                                                                                                      result.getResumeSipPath().replace("_"+l+".xml", ""),
                                                                                                      wfInstanceId,
                                                                                                      result.getPreviousStatusUrls(),
                                                                                                      l, n, "", "", false, GWT.getModuleBaseURL(),SeadApp.tmpHome,
                                                                                                      new AsyncCallback<String>() {
                                                                    
                                                                                                          @Override
                                                                                                          public void onSuccess(final String result) {
                                                                                                              l=-1;
                                                                                                              final Label notify = Util.label("!", "Notification");
                                                                                                              notify.addClickHandler(new ClickHandler() {
                                                                    
                                                                                                                  @Override
                                                                                                                  public void onClick(ClickEvent event) {
                                                                                                                      MessagePopupPanel popUpPanel = new MessagePopupPanel(result, "done", true);
                                                                                                                      popUpPanel.show();
                                                                                                                      nPanel.remove(notify);
                                                                                                                  }
                                                                                                              });
                                                                                                              nPanel.add(notify);
                                                                                                          }
                                                                    
                                                                                                          @Override
                                                                                                          public void onFailure(Throwable caught) {
                                                                    
                                                                                                          }
                                                                                                      });
                                                                                              //Open a status panel that self queries the database for changes
                                                                                          WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(submitterId, wfInstanceId);
                                                                                          eventRefresher.show();
                                                                                          }
                                                                    
                                                                                          @Override
                                                                                          public void onFailure(Throwable caught) {
                                                                    
                                                                                          }
                                                                                      });
                                                                    
                                                                                  }
                                                                                  else{
                                                                                      Window.alert("This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow.");
                                                                                  }
                                                                                  //MediciIngestPresenter.EVENT_BUS.fireEvent(new SubmitSipEvent(
                                                            //                                                result.getResumeSipPath().replace("_"+l+".xml", ""),
                                                            //                                                result.getPreviousStatusUrls()
                                                            //                                                ));
                                                                              }
                                                                    
                                                                          }
                                                                      });
                                                                  }
                                                              });
                                                                  }
                                                            */ int index;
                                                            if (flagHyperlink == 1) {
                                                                index = first;
                                                                first++;
                                                            } else {
                                                                index = last;
                                                                last--;
                                                            }

                                                            grid.setWidget(index, 0, dataset);
                                                            grid.getRowFormatter().setStyleName(index,
                                                                    "DatasetsRow");

                                                        }
                                                    });
                                            it.remove(); // avoids a ConcurrentModificationException
                                        }
                                        //    leftPanel.add(grid);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        // TODO Auto-generated method stub

                                    }
                                });
                            }
                        });
                    } catch (RequestException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });

}

From source file:org.dataconservancy.dcs.access.client.presenter.AcrPublishDataPresenter.java

License:Apache License

void addGetPubHandler() {

    acrProjectList.addChangeHandler(new ChangeHandler() {

        @Override//ww w .  j  a  va 2 s .c o  m
        public void onChange(ChangeEvent event) {
            ROList.clear();
            final NotificationPopupPanel mediciWait = new NotificationPopupPanel("Retrieving", false);
            mediciWait.show();
            previousSelectedFiles = new HashMap<String, List<FileNode>>();
            int selected = acrProjectList.getSelectedIndex();
            final String instance = acrProjectList.getValue(selected);

            mediciService.getAcrInstances(new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {
                    for (MediciInstance ins : result)
                        if (ins.getTitle().equalsIgnoreCase(instance))
                            sparqlEndpoint = ins;
                    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
                            SeadApp.ACRCOMMON + "?instance=" + URL.encodeQueryString(sparqlEndpoint.getTitle())
                                    + "&" + "query="
                                    + URL.encodeQueryString(Query.PROPOSED_FOR_PUBLICATION.getTitle()));

                    rb.setHeader("Content-type", "application/x-www-form-urlencoded");
                    try {
                        Request response = rb.sendRequest(null, new RequestCallback() {
                            @Override
                            public void onError(Request request, Throwable exception) {
                                new ErrorPopupPanel("Error:" + exception.getMessage()).show();
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                String json = response.getText();
                                mediciService.parseJson(json, new AsyncCallback<Map<String, String>>() {

                                    @Override
                                    public void onSuccess(Map<String, String> result) {

                                        //   leftPanel.clear();
                                        JsonpRequestBuilder rb = new JsonpRequestBuilder();
                                        rb.setTimeout(100000);

                                        mediciWait.hide();
                                        last = result.size() - 1;
                                        final FlexTable grid = new FlexTable();
                                        grid.setWidth("100%");
                                        grid.setHeight("100%");

                                        final Iterator it = result.entrySet().iterator();
                                        while (it.hasNext()) {
                                            final Map.Entry pair = (Map.Entry) it.next();
                                            final String dName = (String) pair.getValue();
                                            final String datasetId = (String) pair.getKey();

                                            flagHyperlink = 0;
                                            String tagRetrieveUrl = SeadApp.accessurl + SeadApp.queryPath
                                                    + "?q=resourceValue:" + "(" + URL.encodeQueryString(
                                                            ((String) pair.getKey()).replace(":", "\\:"))
                                                    + ")";
                                            rb.requestObject(tagRetrieveUrl,
                                                    new AsyncCallback<JsSearchResult>() {

                                                        public void onFailure(Throwable caught) {
                                                            Util.reportInternalError(
                                                                    "Matching collection in VA failed", caught);
                                                        }

                                                        public void onSuccess(JsSearchResult result) {

                                                            dataset = Util.label(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    "Hyperlink");
                                                            flagHyperlink = 1;
                                                            ROList.addItem(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    datasetId);

                                                            int index;
                                                            if (flagHyperlink == 1) {
                                                                index = first;
                                                                first++;
                                                            } else {
                                                                index = last;
                                                                last--;
                                                            }

                                                            grid.setWidget(index, 0, dataset);
                                                            grid.getRowFormatter().setStyleName(index,
                                                                    "DatasetsRow");
                                                        }
                                                    });
                                            it.remove(); // avoids a ConcurrentModificationException
                                        }
                                        //    leftPanel.add(grid);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        new ErrorPopupPanel("Error:" + caught.getMessage());
                                    }
                                });
                            }
                        });
                    } catch (RequestException e) {
                        new ErrorPopupPanel("Error:" + e.getMessage());
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    new ErrorPopupPanel("Error:" + caught.getMessage());
                }
            });
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.presenter.EntityPresenter.java

License:Apache License

public static String searchURL(String query, int offset, boolean context, int max, String... params) {

    String s = SeadApp.accessurl + SeadApp.queryPath + "?q=" + URL.encodeQueryString(query) + "&offset="
            + offset + "&max=" + max;

    if (context) {
        s = s + "&_hl=true&_hl.requireFieldMatch=true&_hl.fl=" + URL.encodeQueryString("*");
    }//  w  w  w.j ava  2  s.c  om
    for (int i = 0; i < params.length; i += 2) {
        s = s + "&" + params[i] + "=" + params[i + 1];
    }
    return s;
}

From source file:org.dataconservancy.dcs.access.client.presenter.FacetedSearchPresenter.java

License:Apache License

public static String searchURL(String query, int offset, boolean context, int max, String... params) {

    String decodedQuery = URL.decode(query); //prevent double encoding (Firefox already encodes)
    String encodedQuery = URL.encodeQueryString(decodedQuery);

    String s = SeadApp.accessurl + SeadApp.queryPath + "?q=" + encodedQuery + "&offset=" + offset + "&max="
            + max;/* w ww  . j  ava2 s.c  o m*/

    if (context) {
        s = s + "&_hl=true&_hl.requireFieldMatch=true&_hl.fl=" + URL.encodeQueryString("*");
    }
    for (int i = 0; i < params.length; i += 2) {
        s = s + "&" + params[i] + "=" + params[i + 1];
    }
    return s;
}

From source file:org.dataconservancy.dcs.access.client.presenter.MediciIngestPresenter.java

License:Apache License

void addGetPubHandler() {
    getPub.addClickHandler(new ClickHandler() {

        @Override// ww  w.  java2s.  co m
        public void onClick(ClickEvent event) {
            final StatusPopupPanel mediciWait = new StatusPopupPanel("Retrieving", "wait", false);
            mediciWait.show();
            existingFileSets = new HashMap<String, FileTable>();
            previousSelectedFiles = new HashMap<String, List<FileNode>>();
            int selected = ir.getSelectedIndex();

            final String instance = ir.getValue(selected);

            mediciService.getAcrInstances(new AsyncCallback<List<MediciInstance>>() {

                @Override
                public void onSuccess(List<MediciInstance> result) {

                    for (MediciInstance ins : result)
                        if (ins.getTitle().equalsIgnoreCase(instance))
                            sparqlEndpoint = ins;

                    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
                            SeadApp.ACRCOMMON + "?instance=" + URL.encodeQueryString(sparqlEndpoint.getTitle())
                                    + "&" + "query="
                                    + URL.encodeQueryString(Query.PROPOSED_FOR_PUBLICATION.getTitle()));

                    rb.setHeader("Content-type", "application/x-www-form-urlencoded");

                    try {
                        Request response = rb.sendRequest(null, new RequestCallback() {
                            @Override
                            public void onError(Request request, Throwable exception) {
                                Window.alert("Failed");
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                String json = response.getText();
                                mediciService.parseJson(json, new AsyncCallback<Map<String, String>>() {

                                    @Override
                                    public void onSuccess(Map<String, String> result) {

                                        leftPanel.clear();
                                        JsonpRequestBuilder rb = new JsonpRequestBuilder();
                                        rb.setTimeout(100000);

                                        mediciWait.hide();
                                        last = result.size() - 1;
                                        final FlexTable grid = new FlexTable();
                                        grid.setWidth("100%");
                                        grid.setHeight("100%");

                                        final Iterator it = result.entrySet().iterator();
                                        while (it.hasNext()) {
                                            final Map.Entry pair = (Map.Entry) it.next();
                                            final String dName = (String) pair.getValue();

                                            flagHyperlink = 0;
                                            String tagRetrieveUrl = SeadApp.accessurl + SeadApp.queryPath
                                                    + "?q=resourceValue:" + "(" + URL.encodeQueryString(
                                                            ((String) pair.getKey()).replace(":", "\\:"))
                                                    + ")";
                                            rb.requestObject(tagRetrieveUrl,
                                                    new AsyncCallback<JsSearchResult>() {

                                                        public void onFailure(Throwable caught) {
                                                            Util.reportInternalError(
                                                                    "Matching collection in VA failed", caught);

                                                        }

                                                        public void onSuccess(JsSearchResult result) {
                                                            //                                          if(result.matches().length()==0||sparqlEndpoint.equals("http://sead.ncsa.illinois.edu/acr/resteasy/sparql"))
                                                            //                                          {
                                                            dataset = Util.label(
                                                                    dName.substring(dName.lastIndexOf("/") + 1),
                                                                    "Hyperlink");
                                                            flagHyperlink = 1;
                                                            //                                          }                           
                                                            //                                          else
                                                            //                                              flagHyperlink =0;

                                                            if (flagHyperlink == 1) {
                                                                dataset.addClickHandler(new ClickHandler() {
                                                                    @Override
                                                                    public void onClick(ClickEvent event) {
                                                                        mediciService.restartIngest(
                                                                                (String) pair.getKey(),
                                                                                SeadApp.tmpHome,
                                                                                new AsyncCallback<CheckPointDetail>() {

                                                                                    @Override
                                                                                    public void onFailure(
                                                                                            Throwable caught) {
                                                                                        Window.alert(
                                                                                                "Error in estimating reingest scenario. \n"
                                                                                                        + caught.getMessage());
                                                                                    }

                                                                                    @Override
                                                                                    public void onSuccess(
                                                                                            final CheckPointDetail result) {
                                                                                        if (!result
                                                                                                .isCheckPointed()) {
                                                                                            final StatusPopupPanel collectionWait = new StatusPopupPanel(
                                                                                                    "Querying for BagIt Bag",
                                                                                                    "bag",
                                                                                                    false);
                                                                                            collectionWait
                                                                                                    .show();

                                                                                            final MultiSelectionModel<CollectionNode> selectionModel = new MultiSelectionModel<CollectionNode>();

                                                                                            mediciService
                                                                                                    .getBag((String) pair
                                                                                                            .getKey(),
                                                                                                            sparqlEndpoint,
                                                                                                            SeadApp.bagIturl,
                                                                                                            SeadApp.tmpHome,
                                                                                                            new AsyncCallback<String>() {
                                                                                                                @Override
                                                                                                                public void onSuccess(
                                                                                                                        final String bagPath) {
                                                                                                                    collectionWait
                                                                                                                            .setValue(
                                                                                                                                    "Converting to SEAD SIP",
                                                                                                                                    "wait");

                                                                                                                    final Timer getSIPTimer = new Timer() {

                                                                                                                        @Override
                                                                                                                        public void run() {
                                                                                                                            String tempguid = null;
                                                                                                                            if (((String) pair
                                                                                                                                    .getKey())
                                                                                                                                            .contains(
                                                                                                                                                    "/"))
                                                                                                                                tempguid = ((String) pair
                                                                                                                                        .getKey())
                                                                                                                                                .split("/")[((String) pair
                                                                                                                                                        .getKey())
                                                                                                                                                                .split("/").length
                                                                                                                                                        - 1];
                                                                                                                            else
                                                                                                                                tempguid = ((String) pair
                                                                                                                                        .getKey())
                                                                                                                                                .split(":")[((String) pair
                                                                                                                                                        .getKey())
                                                                                                                                                                .split(":").length
                                                                                                                                                        - 1];
                                                                                                                            final String guid = tempguid;
                                                                                                                            mediciService
                                                                                                                                    .getSipFromBag(
                                                                                                                                            bagPath,
                                                                                                                                            SeadApp.tmpHome
                                                                                                                                                    + guid
                                                                                                                                                    + "_sip.xml",
                                                                                                                                            SeadApp.bagIturl,
                                                                                                                                            new AsyncCallback<String>() {

                                                                                                                                                @Override
                                                                                                                                                public void onSuccess(
                                                                                                                                                        String result) {

                                                                                                                                                    mediciService
                                                                                                                                                            .getFileNos(
                                                                                                                                                                    new AsyncCallback<Integer>() {
                                                                                                                                                                        @Override
                                                                                                                                                                        public void onFailure(
                                                                                                                                                                                Throwable caught) {
                                                                                                                                                                            Window.alert(
                                                                                                                                                                                    "Failed:"
                                                                                                                                                                                            + caught.getMessage());

                                                                                                                                                                        }

                                                                                                                                                                        @Override
                                                                                                                                                                        public void onSuccess(
                                                                                                                                                                                Integer size) {
                                                                                                                                                                            if (size > Constants.MAX) {
                                                                                                                                                                                Window.alert(
                                                                                                                                                                                        "This collection has more than "
                                                                                                                                                                                                + Constants.MAX
                                                                                                                                                                                                + " files.\n"
                                                                                                                                                                                                + "Hence preview is not possible. But you can start the ingest");
                                                                                                                                                                                if (collectionWait
                                                                                                                                                                                        .isShowing())
                                                                                                                                                                                    collectionWait
                                                                                                                                                                                            .hide();
                                                                                                                                                                                getPub.setEnabled(
                                                                                                                                                                                        false);
                                                                                                                                                                                cloudCopy
                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                true);
                                                                                                                                                                                mdCb.setEnabled(
                                                                                                                                                                                        true);
                                                                                                                                                                                ingestButton
                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                true);
                                                                                                                                                                                ir.setEnabled(
                                                                                                                                                                                        false);
                                                                                                                                                                                ir.setStyleName(
                                                                                                                                                                                        "greyFont");
                                                                                                                                                                                getPub.setStyleName(
                                                                                                                                                                                        "greyFont");
                                                                                                                                                                                cloudCopy
                                                                                                                                                                                        .setStyleName(
                                                                                                                                                                                                "greenFont");
                                                                                                                                                                                mdCb.setStyleName(
                                                                                                                                                                                        "greenFont");
                                                                                                                                                                                ingestButton
                                                                                                                                                                                        .setStyleName(
                                                                                                                                                                                                "greenFont");

                                                                                                                                                                                ingestButton
                                                                                                                                                                                        .addClickHandler(
                                                                                                                                                                                                new ClickHandler() {

                                                                                                                                                                                                    @Override
                                                                                                                                                                                                    public void onClick(
                                                                                                                                                                                                            ClickEvent event) {
                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        false);
                                                                                                                                                                                                        cloudCopy
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        false);
                                                                                                                                                                                                        ir.setEnabled(
                                                                                                                                                                                                                false);
                                                                                                                                                                                                        getPub.setEnabled(
                                                                                                                                                                                                                true);
                                                                                                                                                                                                        String rootMediciId = (String) pair
                                                                                                                                                                                                                .getKey();

                                                                                                                                                                                                        AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                                                                                            @Override
                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                    Void result) {
                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                        .addMetadata(
                                                                                                                                                                                                                                metadataSrc,
                                                                                                                                                                                                                                SeadApp.tmpHome
                                                                                                                                                                                                                                        + guid
                                                                                                                                                                                                                                        + "_sip",
                                                                                                                                                                                                                                new AsyncCallback<Void>() {

                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                            Void result) {

                                                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                                                .splitSip(
                                                                                                                                                                                                                                                        SeadApp.tmpHome
                                                                                                                                                                                                                                                                + guid
                                                                                                                                                                                                                                                                + "_sip",
                                                                                                                                                                                                                                                        new AsyncCallback<Integer>() {

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                                                                    Integer result) {
                                                                                                                                                                                                                                                                n = result;
                                                                                                                                                                                                                                                                l++;
                                                                                                                                                                                                                                                                if (l <= n) {
                                                                                                                                                                                                                                                                    mediciService
                                                                                                                                                                                                                                                                            .generateWfInstanceId(
                                                                                                                                                                                                                                                                                    new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                        public void onSuccess(
                                                                                                                                                                                                                                                                                                final String wfInstanceId) {
                                                                                                                                                                                                                                                                                            UserServiceAsync user = GWT
                                                                                                                                                                                                                                                                                                    .create(UserService.class);
                                                                                                                                                                                                                                                                                            user.checkSession(
                                                                                                                                                                                                                                                                                                    null,
                                                                                                                                                                                                                                                                                                    new AsyncCallback<UserSession>() {

                                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                                        public void onFailure(
                                                                                                                                                                                                                                                                                                                Throwable caught) {
                                                                                                                                                                                                                                                                                                            // TODO Auto-generated method stub

                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                                        public void onSuccess(
                                                                                                                                                                                                                                                                                                                UserSession result) {

                                                                                                                                                                                                                                                                                                            mediciService
                                                                                                                                                                                                                                                                                                                    .submitMultipleSips(
                                                                                                                                                                                                                                                                                                                            SeadApp.deposit_endpoint
                                                                                                                                                                                                                                                                                                                                    + "sip",
                                                                                                                                                                                                                                                                                                                            (String) pair
                                                                                                                                                                                                                                                                                                                                    .getKey(),
                                                                                                                                                                                                                                                                                                                            sparqlEndpoint,
                                                                                                                                                                                                                                                                                                                            SeadApp.tmpHome
                                                                                                                                                                                                                                                                                                                                    + guid
                                                                                                                                                                                                                                                                                                                                    + "_sip",
                                                                                                                                                                                                                                                                                                                            wfInstanceId,
                                                                                                                                                                                                                                                                                                                            null,
                                                                                                                                                                                                                                                                                                                            l,
                                                                                                                                                                                                                                                                                                                            n,
                                                                                                                                                                                                                                                                                                                            "",
                                                                                                                                                                                                                                                                                                                            "",
                                                                                                                                                                                                                                                                                                                            false,
                                                                                                                                                                                                                                                                                                                            GWT.getModuleBaseURL(),
                                                                                                                                                                                                                                                                                                                            SeadApp.tmpHome,
                                                                                                                                                                                                                                                                                                                            false,
                                                                                                                                                                                                                                                                                                                            false,
                                                                                                                                                                                                                                                                                                                            new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                                                                @Override
                                                                                                                                                                                                                                                                                                                                public void onSuccess(
                                                                                                                                                                                                                                                                                                                                        final String result) {
                                                                                                                                                                                                                                                                                                                                    l = -1;
                                                                                                                                                                                                                                                                                                                                    final Label notify = Util
                                                                                                                                                                                                                                                                                                                                            .label("!",
                                                                                                                                                                                                                                                                                                                                                    "Notification");
                                                                                                                                                                                                                                                                                                                                    notify.addClickHandler(
                                                                                                                                                                                                                                                                                                                                            new ClickHandler() {

                                                                                                                                                                                                                                                                                                                                                @Override
                                                                                                                                                                                                                                                                                                                                                public void onClick(
                                                                                                                                                                                                                                                                                                                                                        ClickEvent event) {
                                                                                                                                                                                                                                                                                                                                                    StatusPopupPanel mediciWait = new StatusPopupPanel(
                                                                                                                                                                                                                                                                                                                                                            "Retrieving",
                                                                                                                                                                                                                                                                                                                                                            "done",
                                                                                                                                                                                                                                                                                                                                                            false);
                                                                                                                                                                                                                                                                                                                                                    MessagePopupPanel popUpPanel = new MessagePopupPanel(
                                                                                                                                                                                                                                                                                                                                                            result,
                                                                                                                                                                                                                                                                                                                                                            "done",
                                                                                                                                                                                                                                                                                                                                                            true);
                                                                                                                                                                                                                                                                                                                                                    popUpPanel
                                                                                                                                                                                                                                                                                                                                                            .show();
                                                                                                                                                                                                                                                                                                                                                    nPanel.remove(
                                                                                                                                                                                                                                                                                                                                                            notify);
                                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                                            });
                                                                                                                                                                                                                                                                                                                                    nPanel.add(
                                                                                                                                                                                                                                                                                                                                            notify);
                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                @Override
                                                                                                                                                                                                                                                                                                                                public void onFailure(
                                                                                                                                                                                                                                                                                                                                        Throwable caught) {
                                                                                                                                                                                                                                                                                                                                    Window.alert(
                                                                                                                                                                                                                                                                                                                                            "Workflow failed.");
                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                            });

                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                    });
                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                        @Override
                                                                                                                                                                                                                                                                                        public void onFailure(
                                                                                                                                                                                                                                                                                                Throwable caught) {
                                                                                                                                                                                                                                                                                            // TODO Auto-generated method stub

                                                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                                    });

                                                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                                                    Window.alert(
                                                                                                                                                                                                                                                                            "This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow");
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                                                                    Throwable caught) {
                                                                                                                                                                                                                                                                // TODO Auto-generated method stub

                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                        });
                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                                                        // TODO Auto-generated method stub

                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                });
                                                                                                                                                                                                            }

                                                                                                                                                                                                            @Override
                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                    Throwable caught) {
                                                                                                                                                                                                                // TODO Auto-generated method stub

                                                                                                                                                                                                            }
                                                                                                                                                                                                        };
                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                .toVAmodel(
                                                                                                                                                                                                                        rootMediciId,
                                                                                                                                                                                                                        rootMediciId,
                                                                                                                                                                                                                        sparqlEndpoint,
                                                                                                                                                                                                                        SeadApp.tmpHome,
                                                                                                                                                                                                                        vaModelCb);

                                                                                                                                                                                                    }
                                                                                                                                                                                                });

                                                                                                                                                                                coverRightPanel
                                                                                                                                                                                        .setVisible(
                                                                                                                                                                                                true);
                                                                                                                                                                            } else {
                                                                                                                                                                                mediciService
                                                                                                                                                                                        .getRelations(
                                                                                                                                                                                                new AsyncCallback<DatasetRelation>() {

                                                                                                                                                                                                    @Override
                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                        Window.alert(
                                                                                                                                                                                                                "Failed:"
                                                                                                                                                                                                                        + caught.getMessage());

                                                                                                                                                                                                    }

                                                                                                                                                                                                    @Override
                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                            final DatasetRelation relations) {

                                                                                                                                                                                                        display.getDatasetLbl()
                                                                                                                                                                                                                .setText(
                                                                                                                                                                                                                        "Browse Collection and sub-Collections");
                                                                                                                                                                                                        display.getFileLbl()
                                                                                                                                                                                                                .setText(
                                                                                                                                                                                                                        "Browse Files");
                                                                                                                                                                                                        TreeViewModel model = new CollectionTreeViewModel(
                                                                                                                                                                                                                selectionModel,
                                                                                                                                                                                                                relations,
                                                                                                                                                                                                                (String) pair
                                                                                                                                                                                                                        .getKey());
                                                                                                                                                                                                        CellTree.Resources resource = GWT
                                                                                                                                                                                                                .create(TreeResources.class);
                                                                                                                                                                                                        CellTree tree = new CellTree(
                                                                                                                                                                                                                model,
                                                                                                                                                                                                                null,
                                                                                                                                                                                                                resource);
                                                                                                                                                                                                        //collection select
                                                                                                                                                                                                        CollectionSelectEvent
                                                                                                                                                                                                                .register(
                                                                                                                                                                                                                        EVENT_BUS,
                                                                                                                                                                                                                        new CollectionSelectEvent.Handler() {
                                                                                                                                                                                                                            public void onMessageReceived(
                                                                                                                                                                                                                                    final CollectionSelectEvent event) {

                                                                                                                                                                                                                                rightPanel
                                                                                                                                                                                                                                        .clear();
                                                                                                                                                                                                                                rightPanel
                                                                                                                                                                                                                                        .add(getFiles(
                                                                                                                                                                                                                                                relations
                                                                                                                                                                                                                                                        .getDuAttrMap(),
                                                                                                                                                                                                                                                relations
                                                                                                                                                                                                                                                        .getFileAttrMap(),
                                                                                                                                                                                                                                                event.getCollection()
                                                                                                                                                                                                                                                        .getId(),
                                                                                                                                                                                                                                                event.getValue()));
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });

                                                                                                                                                                                                        //collection click
                                                                                                                                                                                                        CollectionClickEvent
                                                                                                                                                                                                                .register(
                                                                                                                                                                                                                        EVENT_BUS,
                                                                                                                                                                                                                        new CollectionClickEvent.Handler() {
                                                                                                                                                                                                                            public void onMessageReceived(
                                                                                                                                                                                                                                    final CollectionClickEvent event) {

                                                                                                                                                                                                                                if (existingFileSets
                                                                                                                                                                                                                                        .containsKey(
                                                                                                                                                                                                                                                event.getCollection()
                                                                                                                                                                                                                                                        .getId())) {
                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .clear();
                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .add(existingFileSets
                                                                                                                                                                                                                                                    .get(event
                                                                                                                                                                                                                                                            .getCollection()
                                                                                                                                                                                                                                                            .getId()).cellTable);
                                                                                                                                                                                                                                } else {

                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .clear();
                                                                                                                                                                                                                                    rightPanel
                                                                                                                                                                                                                                            .add(getFiles(
                                                                                                                                                                                                                                                    relations
                                                                                                                                                                                                                                                            .getDuAttrMap(),
                                                                                                                                                                                                                                                    relations
                                                                                                                                                                                                                                                            .getFileAttrMap(),
                                                                                                                                                                                                                                                    event.getCollection()
                                                                                                                                                                                                                                                            .getId(),
                                                                                                                                                                                                                                                    false));
                                                                                                                                                                                                                                }
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });
                                                                                                                                                                                                        //collection passive click
                                                                                                                                                                                                        CollectionPassiveSelectEvent
                                                                                                                                                                                                                .register(
                                                                                                                                                                                                                        EVENT_BUS,
                                                                                                                                                                                                                        new CollectionPassiveSelectEvent.Handler() {
                                                                                                                                                                                                                            public void onMessageReceived(
                                                                                                                                                                                                                                    final CollectionPassiveSelectEvent event) {

                                                                                                                                                                                                                                CellTable files;
                                                                                                                                                                                                                                if (existingFileSets
                                                                                                                                                                                                                                        .containsKey(
                                                                                                                                                                                                                                                event.getCollection()
                                                                                                                                                                                                                                                        .getId())) {
                                                                                                                                                                                                                                    files = existingFileSets
                                                                                                                                                                                                                                            .get(event
                                                                                                                                                                                                                                                    .getCollection()
                                                                                                                                                                                                                                                    .getId()).cellTable;
                                                                                                                                                                                                                                    for (String file : relations
                                                                                                                                                                                                                                            .getDuAttrMap()
                                                                                                                                                                                                                                            .get(event
                                                                                                                                                                                                                                                    .getCollection()
                                                                                                                                                                                                                                                    .getId())
                                                                                                                                                                                                                                            .getSub()
                                                                                                                                                                                                                                            .get(SubType.File)) {
                                                                                                                                                                                                                                        files.getSelectionModel()
                                                                                                                                                                                                                                                .setSelected(
                                                                                                                                                                                                                                                        (FileNode) relations
                                                                                                                                                                                                                                                                .getFileAttrMap()
                                                                                                                                                                                                                                                                .get(file),
                                                                                                                                                                                                                                                        event.getValue());
                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                    files = (CellTable) getFiles(
                                                                                                                                                                                                                                            relations
                                                                                                                                                                                                                                                    .getDuAttrMap(),
                                                                                                                                                                                                                                            relations
                                                                                                                                                                                                                                                    .getFileAttrMap(),
                                                                                                                                                                                                                                            event.getCollection()
                                                                                                                                                                                                                                                    .getId(),
                                                                                                                                                                                                                                            event.getValue());
                                                                                                                                                                                                                                }

                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });

                                                                                                                                                                                                        collectionWait
                                                                                                                                                                                                                .hide();
                                                                                                                                                                                                        leftPanel
                                                                                                                                                                                                                .clear();
                                                                                                                                                                                                        leftPanel
                                                                                                                                                                                                                .add(tree);

                                                                                                                                                                                                        if (collectionWait
                                                                                                                                                                                                                .isShowing())
                                                                                                                                                                                                            collectionWait
                                                                                                                                                                                                                    .hide();
                                                                                                                                                                                                        getPub.setEnabled(
                                                                                                                                                                                                                false);
                                                                                                                                                                                                        cloudCopy
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        true);
                                                                                                                                                                                                        mdCb.setEnabled(
                                                                                                                                                                                                                true);
                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .setEnabled(
                                                                                                                                                                                                                        true);
                                                                                                                                                                                                        ir.setEnabled(
                                                                                                                                                                                                                false);
                                                                                                                                                                                                        ir.setStyleName(
                                                                                                                                                                                                                "greyFont");
                                                                                                                                                                                                        getPub.setStyleName(
                                                                                                                                                                                                                "greyFont");
                                                                                                                                                                                                        cloudCopy
                                                                                                                                                                                                                .setStyleName(
                                                                                                                                                                                                                        "greenFont");
                                                                                                                                                                                                        mdCb.setStyleName(
                                                                                                                                                                                                                "greenFont");
                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .setStyleName(
                                                                                                                                                                                                                        "greenFont");

                                                                                                                                                                                                        ingestButton
                                                                                                                                                                                                                .addClickHandler(
                                                                                                                                                                                                                        new ClickHandler() {

                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                            public void onClick(
                                                                                                                                                                                                                                    ClickEvent event) {
                                                                                                                                                                                                                                ingestButton
                                                                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                                                                false);
                                                                                                                                                                                                                                cloudCopy
                                                                                                                                                                                                                                        .setEnabled(
                                                                                                                                                                                                                                                false);
                                                                                                                                                                                                                                ir.setEnabled(
                                                                                                                                                                                                                                        false);
                                                                                                                                                                                                                                getPub.setEnabled(
                                                                                                                                                                                                                                        true);
                                                                                                                                                                                                                                String rootMediciId = (String) pair
                                                                                                                                                                                                                                        .getKey();
                                                                                                                                                                                                                                CollectionNode root = relations
                                                                                                                                                                                                                                        .getDuAttrMap()
                                                                                                                                                                                                                                        .get(rootMediciId);

                                                                                                                                                                                                                                AsyncCallback<Void> vaModelCb = new AsyncCallback<Void>() {
                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                            Void result) {
                                                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                                                .addMetadata(
                                                                                                                                                                                                                                                        metadataSrc,
                                                                                                                                                                                                                                                        SeadApp.tmpHome
                                                                                                                                                                                                                                                                + guid
                                                                                                                                                                                                                                                                + "_sip",
                                                                                                                                                                                                                                                        new AsyncCallback<Void>() {

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                                                                    Void result) {
                                                                                                                                                                                                                                                                String tempguid = null;
                                                                                                                                                                                                                                                                if (((String) pair
                                                                                                                                                                                                                                                                        .getKey())
                                                                                                                                                                                                                                                                                .contains(
                                                                                                                                                                                                                                                                                        "/"))
                                                                                                                                                                                                                                                                    tempguid = ((String) pair
                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                    .split("/")[((String) pair
                                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                                    .split("/").length
                                                                                                                                                                                                                                                                                            - 1];
                                                                                                                                                                                                                                                                else
                                                                                                                                                                                                                                                                    tempguid = ((String) pair
                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                    .split(":")[((String) pair
                                                                                                                                                                                                                                                                                            .getKey())
                                                                                                                                                                                                                                                                                                    .split(":").length
                                                                                                                                                                                                                                                                                            - 1];
                                                                                                                                                                                                                                                                final String guid = tempguid;

                                                                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                                                                        .splitSip(
                                                                                                                                                                                                                                                                                SeadApp.tmpHome
                                                                                                                                                                                                                                                                                        + guid
                                                                                                                                                                                                                                                                                        + "_sip",
                                                                                                                                                                                                                                                                                new AsyncCallback<Integer>() {

                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                                                                            Integer result) {
                                                                                                                                                                                                                                                                                        n = result;
                                                                                                                                                                                                                                                                                        l++;

                                                                                                                                                                                                                                                                                        //                                                                                                                     Window.alert("Starting ingest of dataset");//. We already have the cached SIP for this dataset.");
                                                                                                                                                                                                                                                                                        mediciService
                                                                                                                                                                                                                                                                                                .generateWfInstanceId(
                                                                                                                                                                                                                                                                                                        new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                                                                            public void onSuccess(
                                                                                                                                                                                                                                                                                                                    String wfInstanceId) {
                                                                                                                                                                                                                                                                                                                //Open a status panel that self queries the database for changes
                                                                                                                                                                                                                                                                                                                WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(
                                                                                                                                                                                                                                                                                                                        submitterId,
                                                                                                                                                                                                                                                                                                                        wfInstanceId);
                                                                                                                                                                                                                                                                                                                eventRefresher
                                                                                                                                                                                                                                                                                                                        .show();
                                                                                                                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                                                                                                                        .submitMultipleSips(
                                                                                                                                                                                                                                                                                                                                SeadApp.deposit_endpoint
                                                                                                                                                                                                                                                                                                                                        + "sip",
                                                                                                                                                                                                                                                                                                                                (String) pair
                                                                                                                                                                                                                                                                                                                                        .getKey(),
                                                                                                                                                                                                                                                                                                                                sparqlEndpoint,
                                                                                                                                                                                                                                                                                                                                SeadApp.tmpHome
                                                                                                                                                                                                                                                                                                                                        + guid
                                                                                                                                                                                                                                                                                                                                        + "_sip",
                                                                                                                                                                                                                                                                                                                                wfInstanceId,
                                                                                                                                                                                                                                                                                                                                null,
                                                                                                                                                                                                                                                                                                                                l,
                                                                                                                                                                                                                                                                                                                                n,
                                                                                                                                                                                                                                                                                                                                "",
                                                                                                                                                                                                                                                                                                                                "",
                                                                                                                                                                                                                                                                                                                                false,
                                                                                                                                                                                                                                                                                                                                GWT.getModuleBaseURL(),
                                                                                                                                                                                                                                                                                                                                SeadApp.tmpHome,
                                                                                                                                                                                                                                                                                                                                false,
                                                                                                                                                                                                                                                                                                                                false,
                                                                                                                                                                                                                                                                                                                                new AsyncCallback<String>() {

                                                                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                                                                    public void onSuccess(
                                                                                                                                                                                                                                                                                                                                            final String result) {
                                                                                                                                                                                                                                                                                                                                        l = -1;
                                                                                                                                                                                                                                                                                                                                        final Label notify = Util
                                                                                                                                                                                                                                                                                                                                                .label("!",
                                                                                                                                                                                                                                                                                                                                                        "Notification");
                                                                                                                                                                                                                                                                                                                                        notify.addClickHandler(
                                                                                                                                                                                                                                                                                                                                                new ClickHandler() {

                                                                                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                                                                                    public void onClick(
                                                                                                                                                                                                                                                                                                                                                            ClickEvent event) {
                                                                                                                                                                                                                                                                                                                                                        MessagePopupPanel popUpPanel = new MessagePopupPanel(
                                                                                                                                                                                                                                                                                                                                                                result,
                                                                                                                                                                                                                                                                                                                                                                "done",
                                                                                                                                                                                                                                                                                                                                                                true);
                                                                                                                                                                                                                                                                                                                                                        popUpPanel
                                                                                                                                                                                                                                                                                                                                                                .show();
                                                                                                                                                                                                                                                                                                                                                        nPanel.remove(
                                                                                                                                                                                                                                                                                                                                                                notify);
                                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                                });
                                                                                                                                                                                                                                                                                                                                        //                                                                                                                                       nPanel.add(notify);
                                                                                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                                                                                                                            Throwable caught) {

                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                });

                                                                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                                                                                                                    Throwable caught) {

                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                        });

                                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                                                                                                        Window.alert(
                                                                                                                                                                                                                                                                                                "Failed. \n"
                                                                                                                                                                                                                                                                                                        + caught.getMessage());
                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                });
                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                            @Override
                                                                                                                                                                                                                                                            public void onFailure(
                                                                                                                                                                                                                                                                    Throwable caught) {
                                                                                                                                                                                                                                                                Window.alert(
                                                                                                                                                                                                                                                                        "Failed. \n"
                                                                                                                                                                                                                                                                                + caught.getMessage());
                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                        });
                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                    @Override
                                                                                                                                                                                                                                    public void onFailure(
                                                                                                                                                                                                                                            Throwable caught) {
                                                                                                                                                                                                                                        Window.alert(
                                                                                                                                                                                                                                                "Failed. \n"
                                                                                                                                                                                                                                                        + caught.getMessage());
                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                mediciService
                                                                                                                                                                                                                                        .toVAmodel(
                                                                                                                                                                                                                                                rootMediciId,
                                                                                                                                                                                                                                                rootMediciId,
                                                                                                                                                                                                                                                sparqlEndpoint,
                                                                                                                                                                                                                                                SeadApp.tmpHome,
                                                                                                                                                                                                                                                vaModelCb);

                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        });
                                                                                                                                                                                                        coverRightPanel
                                                                                                                                                                                                                .setVisible(
                                                                                                                                                                                                                        true);
                                                                                                                                                                                                    }
                                                                                                                                                                                                });
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    });
                                                                                                                                                }

                                                                                                                                                @Override
                                                                                                                                                public void onFailure(
                                                                                                                                                        Throwable caught) {
                                                                                                                                                    Window.alert(
                                                                                                                                                            "Failed:"
                                                                                                                                                                    + caught.getMessage());

                                                                                                                                                }
                                                                                                                                            });

                                                                                                                        }
                                                                                                                    };
                                                                                                                    getSIPTimer
                                                                                                                            .schedule(
                                                                                                                                    5000);
                                                                                                                }

                                                                                                                @Override
                                                                                                                public void onFailure(
                                                                                                                        Throwable caught) {
                                                                                                                    Window.alert(
                                                                                                                            "Failed:"
                                                                                                                                    + caught.getMessage());

                                                                                                                }
                                                                                                            });

                                                                                        } else {
                                                                                            //restart ingest

                                                                                            n = result
                                                                                                    .getNumSplitSIPs();
                                                                                            String[] arr = result
                                                                                                    .getResumeSipPath()
                                                                                                    .split("_");
                                                                                            int sipNumber = Integer
                                                                                                    .parseInt(
                                                                                                            arr[arr.length
                                                                                                                    - 1].split(
                                                                                                                            "\\.")[0]);
                                                                                            l = sipNumber;
                                                                                            if (l <= n) {

                                                                                                Window.alert(
                                                                                                        "Starting reingest of dataset. We already have the cached SIP for this dataset.");
                                                                                                mediciService
                                                                                                        .generateWfInstanceId(
                                                                                                                new AsyncCallback<String>() {

                                                                                                                    @Override
                                                                                                                    public void onSuccess(
                                                                                                                            String wfInstanceId) {
                                                                                                                        mediciService
                                                                                                                                .submitMultipleSips(
                                                                                                                                        SeadApp.deposit_endpoint
                                                                                                                                                + "sip",
                                                                                                                                        null,
                                                                                                                                        sparqlEndpoint,
                                                                                                                                        result.getResumeSipPath()
                                                                                                                                                .replace(
                                                                                                                                                        "_" + l + ".xml",
                                                                                                                                                        ""),
                                                                                                                                        wfInstanceId,
                                                                                                                                        result.getPreviousStatusUrls(),
                                                                                                                                        l,
                                                                                                                                        n,
                                                                                                                                        "",
                                                                                                                                        "",
                                                                                                                                        false,
                                                                                                                                        GWT.getModuleBaseURL(),
                                                                                                                                        SeadApp.tmpHome,
                                                                                                                                        false,
                                                                                                                                        false,
                                                                                                                                        new AsyncCallback<String>() {

                                                                                                                                            @Override
                                                                                                                                            public void onSuccess(
                                                                                                                                                    final String result) {
                                                                                                                                                l = -1;
                                                                                                                                                final Label notify = Util
                                                                                                                                                        .label("!",
                                                                                                                                                                "Notification");
                                                                                                                                                notify.addClickHandler(
                                                                                                                                                        new ClickHandler() {

                                                                                                                                                            @Override
                                                                                                                                                            public void onClick(
                                                                                                                                                                    ClickEvent event) {
                                                                                                                                                                MessagePopupPanel popUpPanel = new MessagePopupPanel(
                                                                                                                                                                        result,
                                                                                                                                                                        "done",
                                                                                                                                                                        true);
                                                                                                                                                                popUpPanel
                                                                                                                                                                        .show();
                                                                                                                                                                nPanel.remove(
                                                                                                                                                                        notify);
                                                                                                                                                            }
                                                                                                                                                        });
                                                                                                                                                nPanel.add(
                                                                                                                                                        notify);
                                                                                                                                            }

                                                                                                                                            @Override
                                                                                                                                            public void onFailure(
                                                                                                                                                    Throwable caught) {

                                                                                                                                            }
                                                                                                                                        });
                                                                                                                        //Open a status panel that self queries the database for changes
                                                                                                                        WfEventRefresherPanel eventRefresher = new WfEventRefresherPanel(
                                                                                                                                submitterId,
                                                                                                                                wfInstanceId);
                                                                                                                        eventRefresher
                                                                                                                                .show();
                                                                                                                    }

                                                                                                                    @Override
                                                                                                                    public void onFailure(
                                                                                                                            Throwable caught) {

                                                                                                                    }
                                                                                                                });

                                                                                            } else {
                                                                                                Window.alert(
                                                                                                        "This dataset is already ingested. Please clear checkpointing if you want to rerun the workflow.");
                                                                                            }
                                                                                            //MediciIngestPresenter.EVENT_BUS.fireEvent(new SubmitSipEvent(
                                                                                            //                                                result.getResumeSipPath().replace("_"+l+".xml", ""),
                                                                                            //                                                result.getPreviousStatusUrls()
                                                                                            //                                                ));
                                                                                        }

                                                                                    }
                                                                                });
                                                                    }
                                                                });
                                                            }
                                                            int index;
                                                            if (flagHyperlink == 1) {
                                                                index = first;
                                                                first++;
                                                            } else {
                                                                index = last;
                                                                last--;
                                                            }

                                                            grid.setWidget(index, 0, dataset);
                                                            grid.getRowFormatter().setStyleName(index,
                                                                    "DatasetsRow");

                                                        }
                                                    });
                                            it.remove(); // avoids a ConcurrentModificationException
                                        }
                                        leftPanel.add(grid);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        // TODO Auto-generated method stub

                                    }
                                });
                            }
                        });
                    } catch (RequestException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
}