Project

General

Profile

« Previous | Next » 

Revision a3b7c3d9

Added by Andreas Müller almost 2 years ago

add some debugging for finding drush exception

View differences:

src/main/java/eu/etaxonomy/drush/DrushExecuter.java
26 26
import org.apache.log4j.Level;
27 27
import org.apache.log4j.Logger;
28 28

  
29
import com.fasterxml.jackson.core.JsonProcessingException;
29 30
import com.fasterxml.jackson.core.type.TypeReference;
31
import com.fasterxml.jackson.databind.JsonMappingException;
30 32
import com.fasterxml.jackson.databind.ObjectMapper;
31 33

  
32 34
/**
......
183 185
        List<Object> matches = new ArrayList<>();
184 186

  
185 187
        ProcessBuilder pb = new ProcessBuilder(executableWithArgs);
186
        logger.debug("Command: " + pb.command().toString());
188
        logger.warn("Command: " + pb.command().toString());
187 189
        Process process = pb.start();
188 190
        int exitCode = process.waitFor();
189 191

  
......
262 264
     */
263 265
    protected String readExecutionResponse(List<Object> matches, InputStream stream) throws IOException {
264 266
        String out = IOUtils.toString(stream);
265
        if(out != null) {
266
            out = out.trim();
267
            if(!out.isEmpty()) {
268
                ObjectMapper mapper = new ObjectMapper();
269
                if(out.startsWith("[")) {
270
                   matches.add(mapper.readValue(out, new TypeReference<List<Object>>(){}));
271
                } else  {
272
                   matches.add(mapper.readValue(out, Object.class));
273
                }
274
                if(matches.isEmpty()) {
275
                    logger.debug("no result");
276
                } else {
277
                    logger.debug("result object: " + matches.get(0));
267
        try {
268
            if(out != null) {
269
                out = out.trim();
270
                if(!out.isEmpty()) {
271
                    ObjectMapper mapper = new ObjectMapper();
272
                    if(out.startsWith("[")) {
273
                       List<Object> value = mapper.readValue(out, new TypeReference<List<Object>>(){});
274
                       matches.add(value);
275
                    } else  {
276
                       matches.add(mapper.readValue(out, Object.class));
277
                    }
278
                    if(matches.isEmpty()) {
279
                        logger.debug("no result");
280
                    } else {
281
                        logger.debug("result object: " + matches.get(0));
282
                    }
278 283
                }
279
            }
280 284

  
285
            }
286
            return out;
287
        } catch (JsonMappingException  e) {
288
            logger.warn("JsonMappingException for out='"+out+"';" + e.getMessage());
289
            e.printStackTrace();
290
            throw e;
291
        } catch (JsonProcessingException e) {
292
            logger.warn("JsonProcessingException for out='"+out+"';" + e.getMessage());
293
            e.printStackTrace();
294
            throw e;
281 295
        }
282
        return out;
283 296
    }
284 297

  
285 298
    public static class DrushCommand {

Also available in: Unified diff