Project

General

Profile

« Previous | Next » 

Revision 7931

Added by Jing Tao almost 11 years ago

Move a file to the temp dir.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/IndexGenerator.java
334 334
    /*
335 335
     * Write the docids which will be indexed into a file. 
336 336
     */
337
    private void logFile(List<String> ids) throws IOException {
337
    private void logFile(List<String> ids)  {
338 338
        if(ids != null) {
339
            String solrHomeDir = Settings.getConfiguration().getString(SolrServerFactory.SOLR_HOME_PROPERTY_NAME);
340
            File idsForIndex = new File(solrHomeDir, "ids-for-timed-indexing-log");
341
            if(!idsForIndex.exists()) {
342
                idsForIndex.createNewFile();
339
            try {
340
                String tempDir = System.getProperty("java.io.tmpdir");
341
                log.info("the temp dir is ===================== "+tempDir);
342
                File idsForIndex = new File(tempDir, "ids-for-timed-indexing-log");
343
                if(!idsForIndex.exists()) {
344
                    idsForIndex.createNewFile();
345
                }
346
                Date date = Calendar.getInstance().getTime();
347
                SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
348
                String dateStr = format.format(date);
349
                List<String> dateList = new ArrayList<String>();
350
                dateList.add(dateStr);
351
                Boolean append = true;
352
                FileUtils.writeLines(idsForIndex, dateList, append);//write time string
353
                FileUtils.writeLines(idsForIndex, ids, append);
354
            } catch (Exception e) {
355
                log.warn("IndexGenerator.logFile - Couldn't log the ids which will be indexed since - "+e.getMessage());
343 356
            }
344
            Date date = Calendar.getInstance().getTime();
345
            SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
346
            String dateStr = format.format(date);
347
            List<String> dateList = new ArrayList<String>();
348
            dateList.add(dateStr);
349
            Boolean append = true;
350
            FileUtils.writeLines(idsForIndex, dateList, append);//write time string
351
            FileUtils.writeLines(idsForIndex, ids, append);
357
           
352 358
        }
353 359
    }
354 360
    /*

Also available in: Unified diff