Package ca.carleton.gcrc.couch.onUpload

Examples of ca.carleton.gcrc.couch.onUpload.FileConversionActions


  }

  @Override
  public FileConversionActions convertFile(File file, JSONObject doc, CouchDesignDocument dd) throws Exception {
   
    FileConversionActions actions = new FileConversionActions();
   
    GpxFactory factory = new GpxFactory();
    try {
      Gpx gpx = factory.loadFromFile(file);
      if( null == gpx ) {
        throw new Exception("Conversion returns null object");
      }
     
      GpxConversionContext context = new GpxConversionContext();
      context.setLayerName( doc.getString("_id") );
      context.setSourceDocumentId( doc.getString("_id") );
      context.setDesignDocument(dd);
     
      // Creator
      {
        JSONObject creator = doc.optJSONObject("created");
        if( null != creator ) {
          context.setCreated(creator);
        }
      }
     
      // Last Updated
      {
        JSONObject lastUpdated = doc.optJSONObject("lastUpdated");
        if( null != lastUpdated ) {
          context.setLastUpdated(lastUpdated);
        }
      }
     
      convertGpx(context, gpx, doc);
      actions.setDocumentModified(true);
     
      // Upload original file
      actions.addUploadAction( new FileConversionActionUpload("original", "application/xml", file) );
     
      return actions;
     
    } catch(Exception e) {
      throw new Exception("Unable to convert using GPX: "+file.getAbsolutePath(),e);
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.couch.onUpload.FileConversionActions

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.