Ignore:
Timestamp:
02/24/15 16:58:55 (9 years ago)
Author:
emanuel.dima@uni-tuebingen.de
Message:
  1. alpha 21: downloading as text, csv, excel and tcf works
File:
1 moved

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/DataTransfer.java

    r5937 r6043  
    1 package eu.clarin.sru.fcs.aggregator.search;
     1package eu.clarin.sru.fcs.aggregator.rest;
    22
    3 import com.googlecode.sardine.Sardine;
    4 import com.googlecode.sardine.SardineFactory;
    5 import com.googlecode.sardine.impl.SardineException;
    63import com.sun.jersey.api.client.Client;
    74import com.sun.jersey.api.client.ClientResponse;
     
    107import com.sun.jersey.api.client.config.DefaultClientConfig;
    118import java.util.logging.*;
    12 import java.io.IOException;
    139import java.text.SimpleDateFormat;
    1410import java.util.Date;
     
    2723        private static final String WSPACE_AGGREGATOR_DIR = "aggregator_results/";
    2824        private static final String DROP_OFF_URL = "http://ws1-clarind.esc.rzg.mpg.de/drop-off/storage/";
    29 
    30         static void uploadToPW(String user, String pass, byte[] bytes, String mimeType, String fileExtention) {
    31                 try {
    32                         Sardine sardine = SardineFactory.begin();
    33                         sardine.setCredentials(user, pass);
    34                         String outputDir = WSPACE_SERVER_URL + WSPACE_WEBDAV_DIR + WSPACE_AGGREGATOR_DIR;
    35                         if (!sardine.exists(outputDir)) {
    36                                 sardine.createDirectory(outputDir);
    37                         }
    38                         Date currentDate = new Date();
    39                         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS");
    40                         Random generator = new Random();
    41                         int rn1 = generator.nextInt(1000000000);
    42                         String createdFilePath = outputDir + format.format(currentDate) + "-" + rn1 + fileExtention;
    43                         while (sardine.exists(createdFilePath)) {
    44                                 rn1 = generator.nextInt(1000000000);
    45                                 createdFilePath = outputDir + format.format(currentDate) + "-" + rn1 + fileExtention;
    46                         }
    47                         sardine.put(createdFilePath, bytes, mimeType);
    48                         // "Export complete!\nCreated file:\n" + createdFilePath
    49                 } catch (SardineException ex) {
    50                         LOGGER.log(Level.SEVERE, "Error accessing " + WSPACE_SERVER_URL + WSPACE_WEBDAV_DIR, ex);
    51                         //"Wrong name or password!"
    52                 } catch (IOException ex) {
    53                         LOGGER.log(Level.SEVERE, "Error exporting {0} {1} {2}", new String[]{fileExtention, ex.getClass().getName(), ex.getMessage()});
    54                         //"Sorry, export error!"
    55                 }
    56         }
    5725
    5826        static String uploadToDropOff(byte[] bytes, String mimeType, String fileExtention) {
Note: See TracChangeset for help on using the changeset viewer.