Package uk.ac.bbsrc.tgac.miso.core.exception

Examples of uk.ac.bbsrc.tgac.miso.core.exception.SubmissionException


      return (report);
    }
    catch (java.io.FileNotFoundException j) {
      log.debug("The specified datafiles could not be found.");
      throw new SubmissionException("DataFiles could not be found:" + j.getMessage());
    }
    catch (Exception e) {
      e.printStackTrace();
      throw new SubmissionException(e.getMessage());
    }
  }
View Full Code Here


        Set<File> files = new HashSet<File>();
        files.add(new File(filePath.toString()));
        return files;
      }
      else {
        throw new SubmissionException("partition.getPool=null!");
      }
    }
    else {
      throw new SubmissionException("Collection of experiments is empty");
    }
  }
View Full Code Here

  @Override
  public Set<File> generateFilePaths(SequencerPoolPartition partition) throws SubmissionException {
    Set<File> filePaths = new HashSet<File>();
    if((partition.getSequencerPartitionContainer().getRun().getFilePath()) == null){
      throw new SubmissionException("No valid run filepath!");
    }

    Pool<? extends Poolable> pool = partition.getPool();
    if (pool == null) {
      throw new SubmissionException("partition.getPool=null!");
    }
    else {
      Collection<Experiment> experiments = pool.getExperiments();
      if (experiments.isEmpty()) {
        throw new SubmissionException("Collection or experiments is empty");
      }
      else {
        Collection<? extends Dilution> libraryDilutions = pool.getDilutions();
        if (libraryDilutions.isEmpty()) {
          throw new SubmissionException("Collection of libraryDilutions is empty");
        }
        else {
          for (Dilution l : libraryDilutions) {
            Set<File> files = generateFilePath(partition,l);
            filePaths.addAll(files);
View Full Code Here

          fps.add(new File(fp));
        }
        return fps;
      }
      else {
        throw new SubmissionException("No experiments");
      }
    }
    else {
      throw new SubmissionException("Collection of experiments is empty");
    }
  }
View Full Code Here

  @Override
  public Set<File> generateFilePaths(SequencerPoolPartition partition) throws SubmissionException {
    Set<File> filePaths = new HashSet<File>();
    if((partition.getSequencerPartitionContainer().getRun().getFilePath()) == null){
      throw new SubmissionException("No valid run filepath!");
    }

    Pool<? extends Poolable> pool = partition.getPool();
    if (pool == null) {
      throw new SubmissionException("partition.getPool=null!");
    }
    else {
      Collection<Experiment> experiments = pool.getExperiments();
      if (experiments.isEmpty()) {
        throw new SubmissionException("Collection or experiments is empty");
      }
      else {
        Collection<? extends Dilution> libraryDilutions = pool.getDilutions();
        if (libraryDilutions.isEmpty()) {
          throw new SubmissionException("Collection of libraryDilutions is empty");
        }
        else {
          for (Dilution l : libraryDilutions) {
            Set<File> files=generateFilePath(partition,l);
            filePaths.addAll(files);
View Full Code Here

        sb.append(SubmissionUtils.transform(submissionDocument, true));
      }
    }
    catch (ParserConfigurationException e) {
      throw new SubmissionException(e.getMessage());
    }
    catch (TransformerException e) {
      throw new SubmissionException(e.getMessage());
    }
    catch (IOException e) {
      throw new SubmissionException("Cannot write to submission storage directory: " + subPath + ". Please check this directory exists and is writable.");
    }
    finally {
      submissionProperties.remove("submissionDate");
    }
View Full Code Here

    try {

      DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

      if (submissionEndPoint == null) {
        throw new SubmissionException("No submission endpoint configured. Please check your submission.properties file.");
      }

      if (submissionData == null || submissionData.size() == 0) {
        throw new SubmissionException("No submission data set.");
      }

      if (accountName == null || dropBox == null || authKey == null) {
        throw new SubmissionException("An accountName, dropBox and authKey must be supplied!");
      }

      if (centreName == null) {
        throw new SubmissionException("No centreName configured. Please check your submission.properties file and specify your Center Name as given by the SRA.");
      }

      String curl = "curl -k ";

      StringBuilder sb = new StringBuilder();
      sb.append(curl);
      String proxyHost = submissionProperties.getProperty("submission.proxyHost");
      String proxyUser = submissionProperties.getProperty("submission.proxyUser");
      String proxyPass = submissionProperties.getProperty("submission.proxyPass");

      if (proxyHost != null && !proxyHost.equals("")) {
        sb.append("-x ").append(proxyHost);

        if (proxyUser != null && !proxyUser.equals("")) {
          sb.append("-U ").append(proxyUser);

          if (proxyPass != null && !proxyPass.equals("")) {
            sb.append(":").append(proxyPass);
          }
        }
      }

      //submit via REST to endpoint
      try {
        Map<String, List<Submittable<Document>>> map = new HashMap<String, List<Submittable<Document>>>();
        map.put("study", new ArrayList<Submittable<Document>>());
        map.put("sample", new ArrayList<Submittable<Document>>());
        map.put("experiment", new ArrayList<Submittable<Document>>());
        map.put("run", new ArrayList<Submittable<Document>>());

        Document submissionXml = docBuilder.newDocument();
        String subName = null;

        String d = df.format(new Date());
        submissionProperties.put("submissionDate", d);

        for (Submittable<Document> s : submissionData) {
          if (s instanceof Submission) {
            //s.buildSubmission();
            ERASubmissionFactory.generateParentSubmissionXML(submissionXml, (Submission) s, submissionProperties);
            subName = ((Submission) s).getName();
          }
          else if (s instanceof Study) {
            map.get("study").add(s);
          }
          else if (s instanceof Sample) {
            map.get("sample").add(s);
          }
          else if (s instanceof Experiment) {
            map.get("experiment").add(s);
          }
          else if (s instanceof SequencerPoolPartition) {
            map.get("run").add(s);
          }
        }

        if (submissionXml != null && subName != null) {
          String url = getSubmissionEndPoint() + "?auth=ERA%20" + dropBox + "%20" + authKey;
          HttpClient httpclient = getEvilTrustingTrustManager(new DefaultHttpClient());
          HttpPost httppost = new HttpPost(url);
          MultipartEntity reqEntity = new MultipartEntity();

          String submissionXmlFileName = subName + File.separator + subName + "_submission_"+d+".xml";

          File subtmp = new File(submissionStoragePath + submissionXmlFileName);
          SubmissionUtils.transform(submissionXml, subtmp, true);

          reqEntity.addPart("SUBMISSION", new FileBody(subtmp));
          for (String key : map.keySet()) {
            List<Submittable<Document>> submittables = map.get(key);
            String submittableXmlFileName = subName
                                            + File.separator
                                            + subName
                                            + "_"
                                            + key.toLowerCase()
                                            + "_"
                                            + d
                                            + ".xml";
            File elementTmp = new File(submissionStoragePath + submittableXmlFileName);
            Document submissionDocument = docBuilder.newDocument();
            ERASubmissionFactory.generateSubmissionXML(submissionDocument, submittables, key, submissionProperties);
            SubmissionUtils.transform(submissionDocument, elementTmp, true);
            reqEntity.addPart(key.toUpperCase(), new FileBody(elementTmp));
          }

          httppost.setEntity(reqEntity);
          HttpResponse response = httpclient.execute(httppost);

          if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity resEntity = response.getEntity();
            try {
              Document submissionReport = docBuilder.newDocument();
              SubmissionUtils.transform(resEntity.getContent(), submissionReport);
              File savedReport = new File(submissionStoragePath
                                          + subName
                                          + File.separator
                                          + "report_"
                                          + d
                                          + ".xml");
              SubmissionUtils.transform(submissionReport, savedReport);
              return submissionReport;
            }
            catch (IOException e) {
              e.printStackTrace();
            }
            catch (TransformerException e) {
              e.printStackTrace();
            }
            finally {
              submissionProperties.remove("submissionDate");
            }
          }
          else {
            throw new SubmissionException("Response from submission endpoint (" + url + ") was not OK (200). Was: " + response.getStatusLine().getStatusCode());
          }
        }
        else {
          throw new SubmissionException("Could not find a Submission in the supplied set of Submittables");
        }
      }
      catch (IOException e) {
        e.printStackTrace();
      }
View Full Code Here

TOP

Related Classes of uk.ac.bbsrc.tgac.miso.core.exception.SubmissionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.