Project

General

Profile

« Previous | Next » 

Revision 52510

small refactor

View differences:

HTTPWithFileNameCollectorIterable.java
22 22
public class HTTPWithFileNameCollectorIterable implements Iterable<String> {
23 23
    private static final Log log = LogFactory.getLog(HTTPWithFileNameCollectorIterable.class);
24 24
    private static final String TERMINATOR = "FINITO";
25
    private static final String JUNK = "<resource><url>%s</url><DOI>JUNK</DOI></resource>";
25 26
    private final ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<String>(100);
26 27

  
27 28
    private long waitTime = 60L;
......
140 141
            return false;
141 142
        }
142 143

  
143
        private String addFilePath(String meta,String url, boolean isJson){
144
        private String addFilePath(String meta, String url, boolean isJson){
144 145
            String path = url.replace("metadata", "pdf");
145 146

  
146 147
            try {
......
161 162

  
162 163

  
163 164
            if(isJson) {
164
                JSONObject jsonobj = null;
165 165
                try {
166
                    jsonobj = new JSONObject("{'resource':" + meta + "}");
167

  
168
                    return XML.toString(jsonobj);
166
                    return XML.toString(new JSONObject("{'resource':" + meta + "}"));
169 167
                } catch(Exception e) {
170 168
                    log.fatal("Impossible to transform json object to xml \n" + meta + "\n " + e.getMessage() + "\n" + url);
171 169
                   // throw new RuntimeException();
172
                    jsonobj = new JSONObject("{'resource':{'DOI':'JUNK','url':'"+path+"'}}");
173
                    meta = XML.toString(jsonobj);
170
                    final String junk = String.format(JUNK, url);
171
                    log.warn("returning " + junk);
172
                    return junk;
174 173
                }
175 174
            }
176 175
            return meta;

Also available in: Unified diff