Example usage for java.io IOException fillInStackTrace

List of usage examples for java.io IOException fillInStackTrace

Introduction

In this page you can find the example usage for java.io IOException fillInStackTrace.

Prototype

public synchronized Throwable fillInStackTrace() 

Source Link

Document

Fills in the execution stack trace.

Usage

From source file:de.nmichael.efa.Daten.java

private static boolean istSchluesselGedrehtIntern() {
    String gpio = Daten.efaBaseConfig.efaUserDirectory + Daten.fileSep;
    File fileGpio = new File(gpio + "value");
    File fileGut = new File(gpio + "value.gut.txt");
    try {//from ww w  .j ava  2s. c  o  m
        String contentsGpio = FileUtils.readFileToString(fileGpio);
        String contentsGut = FileUtils.readFileToString(fileGut);
        return contentsGut.equals(contentsGpio);
        // return FileUtils.contentEquals(file1, file2);
    } catch (IOException e) {
        Logger.log(e);
        Dialog.exceptionError(e.getMessage(), e.fillInStackTrace().toString());
        return false;
    }
}

From source file:com.hp.test.framework.model.testcasegen.TestCaseGenerator.java

void purgeDirectory(File dir) {
    //    for (File file: dir.listFiles()) {
    //        if (file.isDirectory()) purgeDirectory(file);
    //        file.delete();
    try {//from w  w  w  . jav  a 2  s.c o  m
        FileUtils.cleanDirectory(dir);
        log.info("Cleared the template directory");
    } catch (IOException e) {
        log.error("Clean directory issue" + e.fillInStackTrace());
    }
}

From source file:netscape.security.pkcs.PKCS7.java

/**
 * Encodes the signed data to a DerOutputStream.
 *
 * @param out the DerOutputStream to write the encoded data to.
 * @exception IOException on encoding errors.
 *///w  w w  .  j av a  2 s.  com
public void encodeSignedData(DerOutputStream out, boolean sort) throws IOException {

    DerOutputStream signedData = new DerOutputStream();

    // version
    signedData.putInteger(version);

    // digestAlgorithmIds
    signedData.putOrderedSetOf(DerValue.tag_Set, digestAlgorithmIds);

    // contentInfo
    contentInfo.encode(signedData);

    // cast to X509CertImpl[] since X509CertImpl implements DerEncoder
    X509CertImpl implCerts[] = new X509CertImpl[certificates.length];
    try {
        for (int i = 0; i < certificates.length; i++) {
            implCerts[i] = (X509CertImpl) certificates[i];
        }
    } catch (ClassCastException e) {
        IOException ioe = new IOException(
                "Certificates in PKCS7 " + "must be of class " + "netscape.security.X509CertImpl");
        ioe.fillInStackTrace();
    }

    // Add the certificate set (tagged with [0] IMPLICIT)
    // to the signed data
    if (sort) {
        signedData.putOrderedSetOf((byte) 0xA0, implCerts);
    } else {
        signedData.putSet((byte) 0xA0, implCerts);
    }

    // no crls (OPTIONAL field)

    // signerInfos
    signedData.putOrderedSetOf(DerValue.tag_Set, signerInfos);

    // making it a signed data block
    DerValue signedDataSeq = new DerValue(DerValue.tag_Sequence, signedData.toByteArray());

    // making it a content info sequence
    ContentInfo block = new ContentInfo(ContentInfo.SIGNED_DATA_OID, signedDataSeq);

    // writing out the contentInfo sequence
    block.encode(out);
}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java

private synchronized void createWorkspacePersistenceFile() {
    try {//from   w w  w  . j av a2s .co m
        String workSpaceFileName = applicationService.getApplicationProperty("view.persistence.file.location");
        logger.debug("workSpaceFileName = " + workSpaceFileName);
        logger.debug("applicationService.getApplicationProperty(\"installation.folder\") = "
                + applicationService.getApplicationProperty("installation.folder"));
        workspaceFile = new File(applicationService.getApplicationProperty("installation.folder"),
                workSpaceFileName);
        // create file if it doesn't exist
        if (!workspaceFile.exists()) {
            boolean result = workspaceFile.createNewFile();
            if (!result) {
                workspaceFileEnabled = false;
                logger.warn("Unable to create workspace file!");
            } else {
                workspaceFileEnabled = true;
            }
        } else if (workspaceFile.canRead() && workspaceFile.canWrite()) {
            workspaceFileEnabled = true;
        }
    } catch (IOException e) {
        logger.warn("IO exception. Nested exception is : " + e.fillInStackTrace());
        // set property workspaceFileEnabled to false
        workspaceFileEnabled = false;
    }
}

From source file:org.apache.tez.runtime.library.common.shuffle.impl.ShuffleScheduler.java

public synchronized void copyFailed(InputAttemptIdentifier srcAttempt, MapHost host, boolean readError) {
    host.penalize();/* ww  w .  j av a 2 s.  co m*/
    int failures = 1;
    if (failureCounts.containsKey(srcAttempt)) {
        IntWritable x = failureCounts.get(srcAttempt);
        x.set(x.get() + 1);
        failures = x.get();
    } else {
        failureCounts.put(srcAttempt, new IntWritable(1));
    }
    String hostname = host.getHostName();
    if (hostFailures.containsKey(hostname)) {
        IntWritable x = hostFailures.get(hostname);
        x.set(x.get() + 1);
    } else {
        hostFailures.put(hostname, new IntWritable(1));
    }
    if (failures >= abortFailureLimit) {
        IOException ioe = new IOException(failures + " failures downloading "
                + TezRuntimeUtils.getTaskAttemptIdentifier(inputContext.getSourceVertexName(),
                        srcAttempt.getInputIdentifier().getSrcTaskIndex(), srcAttempt.getAttemptNumber()));
        ioe.fillInStackTrace();
        shuffle.reportException(ioe);
    }

    checkAndInformJobTracker(failures, srcAttempt, readError);

    checkReducerHealth();

    long delay = (long) (INITIAL_PENALTY * Math.pow(PENALTY_GROWTH_RATE, failures));

    penalties.add(new Penalty(host, delay));

    failedShuffleCounter.increment(1);
}

From source file:org.apache.wiki.providers.BasicAttachmentProvider.java

/**
 *  {@inheritDoc}//from  w w w. j ava  2s . c  o m
 */
public void putAttachmentData(Attachment att, InputStream data) throws ProviderException, IOException {
    OutputStream out = null;
    File attDir = findAttachmentDir(att);

    if (!attDir.exists()) {
        attDir.mkdirs();
    }

    int latestVersion = findLatestVersion(att);

    // System.out.println("Latest version is "+latestVersion);

    try {
        int versionNumber = latestVersion + 1;

        File newfile = new File(attDir, versionNumber + "." + getFileExtension(att.getFileName()));

        log.info("Uploading attachment " + att.getFileName() + " to page " + att.getParentName());
        log.info("Saving attachment contents to " + newfile.getAbsolutePath());
        out = new FileOutputStream(newfile);

        FileUtil.copyContents(data, out);

        Properties props = getPageProperties(att);

        String author = att.getAuthor();

        if (author == null) {
            author = "unknown"; // FIXME: Should be localized, but cannot due to missing WikiContext
        }

        props.setProperty(versionNumber + ".author", author);

        String changeNote = (String) att.getAttribute(WikiPage.CHANGENOTE);
        if (changeNote != null) {
            props.setProperty(versionNumber + ".changenote", changeNote);
        }

        putPageProperties(att, props);
    } catch (IOException e) {
        log.error("Could not save attachment data: ", e);
        IOUtils.closeQuietly(out);
        throw (IOException) e.fillInStackTrace();
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleScheduler.java

public synchronized void copyFailed(InputAttemptIdentifier srcAttempt, MapHost host, boolean readError,
        boolean connectError) {
    host.penalize();//from   www .jav  a 2s .  c om
    int failures = 1;
    if (failureCounts.containsKey(srcAttempt)) {
        IntWritable x = failureCounts.get(srcAttempt);
        x.set(x.get() + 1);
        failures = x.get();
    } else {
        failureCounts.put(srcAttempt, new IntWritable(1));
    }
    String hostPort = host.getHostIdentifier();
    // TODO TEZ-922 hostFailures isn't really used for anything. Factor it into error
    // reporting / potential blacklisting of hosts.
    if (hostFailures.containsKey(hostPort)) {
        IntWritable x = hostFailures.get(hostPort);
        x.set(x.get() + 1);
    } else {
        hostFailures.put(hostPort, new IntWritable(1));
    }
    if (failures >= abortFailureLimit) {
        // This task has seen too many fetch failures - report it as failed. The
        // AM may retry it if max failures has not been reached.

        // Between the task and the AM - someone needs to determine who is at
        // fault. If there's enough errors seen on the task, before the AM informs
        // it about source failure, the task considers itself to have failed and
        // allows the AM to re-schedule it.
        IOException ioe = new IOException(failures + " failures downloading "
                + TezRuntimeUtils.getTaskAttemptIdentifier(inputContext.getSourceVertexName(),
                        srcAttempt.getInputIdentifier().getInputIndex(), srcAttempt.getAttemptNumber()));
        ioe.fillInStackTrace();
        // Shuffle knows how to deal with failures post shutdown via the onFailure hook
        shuffle.reportException(ioe);
    }

    failedShuffleCounter.increment(1);
    checkAndInformAM(failures, srcAttempt, readError, connectError);

    checkReducerHealth();

    long delay = (long) (INITIAL_PENALTY * Math.pow(PENALTY_GROWTH_RATE, failures));

    penalties.add(new Penalty(host, delay));
}

From source file:org.openmrs.module.FacesRegister.web.controller.Faces361BRegisterManageController.java

@RequestMapping(value = "/module/FacesRegister/download", method = RequestMethod.POST) //called when the user clicks on the download link
public void getCSV(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(value = "location", required = true) String location,
        @RequestParam(value = "Startdate", required = true) String artsDate,
        @RequestParam(value = "Enddate", required = true) String cendDate) {

    // Do Stuff with the location, and date

    log.info(location);//from  www.j a v a 2 s . c o m
    log.info(artsDate);
    log.info(location);
    log.info(cendDate);
    log.info(dateFormat(cendDate));
    RegisterService service = Context.getService(RegisterService.class);
    Location l = Context.getLocationService().getLocation(location); //get the Id for the selected site/facility
    log.info("Selected Location " + l.getLocationId() + " - " + l.getName());
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
        HashMap<Patient, String> patients = service.getPatientsGivenArtDates(l.getLocationId(),
                sdf.parse(artsDate), sdf.parse(cendDate));
        //Convert patients to persons
        List<Person> person = new ArrayList<Person>();
        for (Patient px : patients.keySet())
            person.add(px);

        List<ArtRegister> artRegister = new ArrayList<ArtRegister>();
        //HashMap<Patient, Date> artdates=service.getArtStartDates(person,l.getLocationId());
        HashMap<Patient, String> whoStage = service.getStatusatStartArtWHO(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        //HashMap<Patient, String>cd4=service.getCD4CountAtStart(person, sdf.parse(artsDate), sdf.parse(cendDate));
        HashMap<Patient, String> cd4Count = service.getCD4CountAtStart(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        HashMap<Patient, String> weight = service.getWeightatStart(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        HashMap<Patient, String> height = service.getWeightatStart(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        HashMap<Patient, String> originalRegimen = service.getOriginalRegimen(person);
        HashMap<Patient, ArtChanges> secondLineRegList = service.getSecondlineHAARTReg(person);
        HashMap<Patient, String> ctx = service.getCtxStart(person);
        HashMap<Patient, String> tb = service.getTBStart(person);
        HashMap<Patient, String> inh = service.getINHStart(person);
        List<ArtChanges> firstlineSub = service.getFirstLineHAARTsub(person);
        List<ArtChanges> secondlineSub = service.getSecondLineHAARTSub(person);
        HashMap<Patient, String> monthly[];
        HashMap<Patient, String> patientMonthlyStatus[];
        Integer n = service.getMonths(sdf.parse(cendDate));
        monthly = new HashMap[n];

        for (int i = 0; i < n; i++) {
            monthly[i] = service.getMonthlyReg(person, sdf.parse(cendDate), i + 1);
        }

        patientMonthlyStatus = new HashMap[n];
        for (int i = 0; i < n; i++) {
            patientMonthlyStatus[i] = service.getPatientStatusByMonth(person, sdf.parse(cendDate), i + 1);
        }
        /*
         * Get six month interval patient status
         * n guides the number six monthly status that can be fetched  
         */

        HashMap<Patient, PatientStatus> sixMonStatus[] = new HashMap[8];//
        if (n >= 6) // get month 6 status (Cd4, tb status and weight)
            sixMonStatus[0] = service.getSixMonthStatus(person, sdf.parse(artsDate), 0, 6);
        if (n >= 12) // get month 12 status (Cd4, tb status and weight)
            sixMonStatus[1] = service.getSixMonthStatus(person, sdf.parse(artsDate), 6, 12);
        if (n >= 18) // get month 18 status (Cd4, tb status and weight)
            sixMonStatus[2] = service.getSixMonthStatus(person, sdf.parse(artsDate), 12, 18);
        if (n >= 24) // get month 24 status (Cd4, tb status and weight)
            sixMonStatus[3] = service.getSixMonthStatus(person, sdf.parse(artsDate), 18, 24);
        if (n >= 30) // get month 30 status (Cd4, tb status and weight)
            sixMonStatus[4] = service.getSixMonthStatus(person, sdf.parse(artsDate), 24, 30);
        if (n >= 36) // get month 36 status (Cd4, tb status and weight)
            sixMonStatus[5] = service.getSixMonthStatus(person, sdf.parse(artsDate), 30, 36);
        if (n >= 42) // get month 42 status (Cd4, tb status and weight)
            sixMonStatus[6] = service.getSixMonthStatus(person, sdf.parse(artsDate), 36, 42);
        if (n >= 48) // get month 48 status (Cd4, tb status and weight)
            sixMonStatus[7] = service.getSixMonthStatus(person, sdf.parse(artsDate), 42, 48);

        int serial = 1;

        for (Patient p : patients.keySet()) {
            ArtRegister artRcd = new ArtRegister();
            artRcd.setPatient(p);
            artRcd.setId(serial);
            artRcd.setArtStartDate(patients.get(p));
            artRcd.setWhoStage(whoStage.get(p));
            artRcd.setCd4Count(cd4Count.get(p));
            artRcd.setWeightStartArt(weight.get(p));
            artRcd.setHeightStartArt(height.get(p));
            artRcd.setOriginalReg(originalRegimen.get(p));
            artRcd.setCtxStart(ctx.get(p));
            artRcd.setInhStart(inh.get(p));
            artRcd.setTbStart(tb.get(p));
            artRcd.setnMonths(n);

            /*
             * Creating a list of monthly regimen prescriptions for the current patient
             */
            List<String> monthlyReg = new ArrayList<String>();
            for (int x = 0; x < n; x++) {
                monthlyReg.add(monthly[x].get(p));
            }
            artRcd.setMonthlyVisit(monthlyReg);

            /*
             * Creating a list of monthly patient status STOP, DEAD, LOST or TO
             */
            List<String> monthlyStatus = new ArrayList<String>();
            for (int x = 0; x < n; x++) {
                monthlyStatus.add(patientMonthlyStatus[x].get(p));
            }
            artRcd.setPatientStatus(monthlyStatus);

            /*
             * Creating a list of current patient first HAART sub
             */
            List<ArtChanges> curPatientHaartSubs = new ArrayList<ArtChanges>();
            for (int x = 0; x < firstlineSub.size(); x++) {
                if (p.equals(firstlineSub.get(x).getPatient()))
                    curPatientHaartSubs.add(firstlineSub.get(x));
            }
            artRcd.setFirstLineSub(curPatientHaartSubs);

            /*
             * Creating a list of current patient second line HAART substitutions
             */
            List<ArtChanges> curPatientSecondSubs = new ArrayList<ArtChanges>();
            for (int x = 0; x < secondlineSub.size(); x++) {
                if (p.equals(secondlineSub.get(x).getPatient()))
                    curPatientSecondSubs.add(secondlineSub.get(x));
            }
            artRcd.setSecondLineSub(curPatientSecondSubs);

            /*
             * Get six month interval patient status
             * n guides the number monthly status fetched  
             */
            //month 6 status
            List<PatientStatus> curPatStatus = new ArrayList<PatientStatus>();
            if (n >= 6)
                curPatStatus.add(sixMonStatus[0].get(p));
            if (n >= 12)
                curPatStatus.add(sixMonStatus[1].get(p));
            if (n >= 18)
                curPatStatus.add(sixMonStatus[2].get(p));
            if (n >= 24)
                curPatStatus.add(sixMonStatus[3].get(p));
            if (n >= 30)
                curPatStatus.add(sixMonStatus[4].get(p));
            if (n >= 36)
                curPatStatus.add(sixMonStatus[5].get(p));
            if (n >= 42)
                curPatStatus.add(sixMonStatus[6].get(p));
            if (n >= 48)
                curPatStatus.add(sixMonStatus[7].get(p));

            artRcd.setSixMonthlyStatus(curPatStatus);

            /*
             * Get second line regimen
             * 
             */
            artRcd.setSecondLineReg(secondLineRegList.get(p));

            serial++;
            artRegister.add(artRcd);

        }

        RegisterRenderer renderer = new RegisterRenderer();
        //call the save/open dialog box of the web browser
        response.setHeader("Content-Disposition", "attachment;filename=ART_REGISTER_361B.csv");
        response.setContentType("application/csv");
        try {
            //response.getWriter().write(csv.toString()); // this is usually called when using string builder and should be placed in the controller class. see the definition of string builder in render2 in CSVRenderer
            renderer.csvRender(artRegister, response.getOutputStream(), n, sdf.parse(cendDate));//call the render method from CsvRenderer
        } catch (IOException e) {
            // TODO Auto-generated catch block
            log.info("Error when creating the CSV file");
        }
    } catch (Exception e) {
        log.error("Error " + e.getMessage() + " \n " + e.fillInStackTrace());
    }

}

From source file:org.openmrs.module.FacesRegister.web.controller.Faces361BRegisterManageController.java

@RequestMapping(value = "/module/FacesRegister/downloadExcel", method = RequestMethod.POST) //called when the user clicks on the download link
public void getExcel(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(value = "location", required = true) String location,
        @RequestParam(value = "Startdate", required = true) String artsDate,
        @RequestParam(value = "Enddate", required = true) String cendDate) {

    // Do Stuff with the location, and date

    log.info(location);/*from ww  w . j ava 2  s  .c  o  m*/
    log.info(artsDate);
    log.info(location);
    log.info(cendDate);
    log.info(dateFormat(cendDate));
    RegisterService service = Context.getService(RegisterService.class);
    Location l = Context.getLocationService().getLocation(location); //get the Id for the selected site/facility
    log.info("Selected Location " + l.getLocationId() + " - " + l.getName());
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
        HashMap<Patient, String> patients = service.getPatientsGivenArtDates(l.getLocationId(),
                sdf.parse(artsDate), sdf.parse(cendDate));
        //Convert patients to persons
        List<Person> person = new ArrayList<Person>();
        for (Patient px : patients.keySet())
            person.add(px);

        List<ArtRegister> artRegister = new ArrayList<ArtRegister>();
        //HashMap<Patient, Date> artdates=service.getArtStartDates(person,l.getLocationId());
        HashMap<Patient, String> whoStage = service.getStatusatStartArtWHO(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        //HashMap<Patient, String>cd4=service.getCD4CountAtStart(person, sdf.parse(artsDate), sdf.parse(cendDate));
        HashMap<Patient, String> cd4Count = service.getCD4CountAtStart(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        HashMap<Patient, String> weight = service.getWeightatStart(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        HashMap<Patient, String> height = service.getWeightatStart(person, sdf.parse(artsDate),
                sdf.parse(cendDate));
        HashMap<Patient, String> originalRegimen = service.getOriginalRegimen(person);
        HashMap<Patient, ArtChanges> secondLineRegList = service.getSecondlineHAARTReg(person);
        HashMap<Patient, String> ctx = service.getCtxStart(person);
        HashMap<Patient, String> tb = service.getTBStart(person);
        HashMap<Patient, String> inh = service.getINHStart(person);
        List<ArtChanges> firstlineSub = service.getFirstLineHAARTsub(person);
        List<ArtChanges> secondlineSub = service.getSecondLineHAARTSub(person);
        HashMap<Patient, String> monthly[];
        HashMap<Patient, String> patientMonthlyStatus[];
        Integer n = service.getMonths(sdf.parse(cendDate));
        monthly = new HashMap[n];

        for (int i = 0; i < n; i++) {
            monthly[i] = service.getMonthlyReg(person, sdf.parse(cendDate), i + 1);
        }

        patientMonthlyStatus = new HashMap[n];
        for (int i = 0; i < n; i++) {
            patientMonthlyStatus[i] = service.getPatientStatusByMonth(person, sdf.parse(cendDate), i + 1);
        }
        /*
         * Get six month interval patient status
         * n guides the number six monthly status that can be fetched  
         */

        HashMap<Patient, PatientStatus> sixMonStatus[] = new HashMap[8];//
        if (n >= 6) // get month 6 status (Cd4, tb status and weight)
            sixMonStatus[0] = service.getSixMonthStatus(person, sdf.parse(artsDate), 0, 6);
        if (n >= 12) // get month 12 status (Cd4, tb status and weight)
            sixMonStatus[1] = service.getSixMonthStatus(person, sdf.parse(artsDate), 6, 12);
        if (n >= 18) // get month 18 status (Cd4, tb status and weight)
            sixMonStatus[2] = service.getSixMonthStatus(person, sdf.parse(artsDate), 12, 18);
        if (n >= 24) // get month 24 status (Cd4, tb status and weight)
            sixMonStatus[3] = service.getSixMonthStatus(person, sdf.parse(artsDate), 18, 24);
        if (n >= 30) // get month 30 status (Cd4, tb status and weight)
            sixMonStatus[4] = service.getSixMonthStatus(person, sdf.parse(artsDate), 24, 30);
        if (n >= 36) // get month 36 status (Cd4, tb status and weight)
            sixMonStatus[5] = service.getSixMonthStatus(person, sdf.parse(artsDate), 30, 36);
        if (n >= 42) // get month 42 status (Cd4, tb status and weight)
            sixMonStatus[6] = service.getSixMonthStatus(person, sdf.parse(artsDate), 36, 42);
        if (n >= 48) // get month 48 status (Cd4, tb status and weight)
            sixMonStatus[7] = service.getSixMonthStatus(person, sdf.parse(artsDate), 42, 48);

        int serial = 1;

        for (Patient p : patients.keySet()) {
            ArtRegister artRcd = new ArtRegister();
            artRcd.setPatient(p);
            artRcd.setId(serial);
            artRcd.setArtStartDate(patients.get(p));
            artRcd.setWhoStage(whoStage.get(p));
            artRcd.setCd4Count(cd4Count.get(p));
            artRcd.setWeightStartArt(weight.get(p));
            artRcd.setHeightStartArt(height.get(p));
            artRcd.setOriginalReg(originalRegimen.get(p));
            artRcd.setCtxStart(ctx.get(p));
            artRcd.setInhStart(inh.get(p));
            artRcd.setTbStart(tb.get(p));
            artRcd.setnMonths(n);

            /*
             * Creating a list of monthly regimen prescriptions for the current patient
             */
            List<String> monthlyReg = new ArrayList<String>();
            for (int x = 0; x < n; x++) {
                monthlyReg.add(monthly[x].get(p));
            }
            artRcd.setMonthlyVisit(monthlyReg);

            /*
             * Creating a list of monthly patient status STOP, DEAD, LOST or TO
             */
            List<String> monthlyStatus = new ArrayList<String>();
            for (int x = 0; x < n; x++) {
                monthlyStatus.add(patientMonthlyStatus[x].get(p));
            }
            artRcd.setPatientStatus(monthlyStatus);

            /*
             * Creating a list of current patient first HAART sub
             */
            List<ArtChanges> curPatientHaartSubs = new ArrayList<ArtChanges>();
            for (int x = 0; x < firstlineSub.size(); x++) {
                if (p.equals(firstlineSub.get(x).getPatient()))
                    curPatientHaartSubs.add(firstlineSub.get(x));
            }
            artRcd.setFirstLineSub(curPatientHaartSubs);

            /*
             * Creating a list of current patient second line HAART substitutions
             */
            List<ArtChanges> curPatientSecondSubs = new ArrayList<ArtChanges>();
            for (int x = 0; x < secondlineSub.size(); x++) {
                if (p.equals(secondlineSub.get(x).getPatient()))
                    curPatientSecondSubs.add(secondlineSub.get(x));
            }
            artRcd.setSecondLineSub(curPatientSecondSubs);

            /*
             * Get six month interval patient status
             * n guides the number monthly status fetched  
             */
            //month 6 status
            List<PatientStatus> curPatStatus = new ArrayList<PatientStatus>();
            if (n >= 6)
                curPatStatus.add(sixMonStatus[0].get(p));
            if (n >= 12)
                curPatStatus.add(sixMonStatus[1].get(p));
            if (n >= 18)
                curPatStatus.add(sixMonStatus[2].get(p));
            if (n >= 24)
                curPatStatus.add(sixMonStatus[3].get(p));
            if (n >= 30)
                curPatStatus.add(sixMonStatus[4].get(p));
            if (n >= 36)
                curPatStatus.add(sixMonStatus[5].get(p));
            if (n >= 42)
                curPatStatus.add(sixMonStatus[6].get(p));
            if (n >= 48)
                curPatStatus.add(sixMonStatus[7].get(p));

            artRcd.setSixMonthlyStatus(curPatStatus);

            /*
             * Get second line regimen
             * 
             */
            artRcd.setSecondLineReg(secondLineRegList.get(p));

            serial++;
            artRegister.add(artRcd);

        }

        RegisterRenderer renderer = new RegisterRenderer();
        //call the save/open dialog box of the web browser
        response.setHeader("Content-Disposition", "attachment;filename=/resources/RegisterTemplate.xls");
        response.setContentType("application/vnd.ms-excel");
        try {
            //response.getWriter().write(csv.toString()); // this is usually called when using string builder and should be placed in the controller class. see the definition of string builder in render2 in CSVRenderer
            renderer.excelRender((List) patients.keySet(), response.getOutputStream());//call the render method from ExcelRenderer
        } catch (IOException e) {
            // TODO Auto-generated catch block
            log.info("Error when creating the CSV file");
        }
    } catch (Exception e) {
        log.error("Error " + e.getMessage() + " \n " + e.fillInStackTrace());
    }

}

From source file:org.jbpm.executor.impl.ExecutorRunnable.java

@SuppressWarnings("unchecked")
public void run() {
    logger.debug("Executor Thread {} Waking Up!!!", this.toString());
    try {//from   w ww  .j a v  a2s. co m
        RequestInfo request = (RequestInfo) queryService.getRequestForProcessing();
        if (request != null) {
            CommandContext ctx = null;
            List<CommandCallback> callbacks = null;
            try {

                logger.debug("Processing Request Id: {}, status {} command {}", request.getId(),
                        request.getStatus(), request.getCommandName());
                ClassLoader cl = getClassLoader(request.getDeploymentId());

                byte[] reqData = request.getRequestData();
                if (reqData != null) {
                    ObjectInputStream in = null;
                    try {
                        in = new ClassLoaderObjectInputStream(cl, new ByteArrayInputStream(reqData));
                        ctx = (CommandContext) in.readObject();
                    } catch (IOException e) {
                        logger.warn("Exception while serializing context data", e);
                        return;
                    } finally {
                        if (in != null) {
                            in.close();
                        }
                    }
                }
                callbacks = classCacheManager.buildCommandCallback(ctx, cl);

                Command cmd = classCacheManager.findCommand(request.getCommandName(), cl);
                ExecutionResults results = cmd.execute(ctx);
                for (CommandCallback handler : callbacks) {

                    handler.onCommandDone(ctx, results);
                }

                if (results != null) {
                    try {
                        ByteArrayOutputStream bout = new ByteArrayOutputStream();
                        ObjectOutputStream out = new ObjectOutputStream(bout);
                        out.writeObject(results);
                        byte[] respData = bout.toByteArray();
                        request.setResponseData(respData);
                    } catch (IOException e) {
                        request.setResponseData(null);
                    }
                }

                request.setStatus(STATUS.DONE);
                commandService.execute(new MergeObjectCommand(request));

            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            } catch (Throwable e) {
                logger.warn("Error during command {} execution {}", request.getCommandName(), e.getMessage());

                ErrorInfo errorInfo = new ErrorInfo(e.getMessage(),
                        ExceptionUtils.getFullStackTrace(e.fillInStackTrace()));
                errorInfo.setRequestInfo(request);

                ((List<ErrorInfo>) request.getErrorInfo()).add(errorInfo);
                logger.debug("Error Number: {}", request.getErrorInfo().size());
                if (request.getRetries() > 0) {
                    request.setStatus(STATUS.RETRYING);
                    request.setRetries(request.getRetries() - 1);
                    request.setExecutions(request.getExecutions() + 1);
                    logger.debug("Retrying ({}) still available!", request.getRetries());

                    commandService.execute(new MergeObjectCommand(request));
                } else {
                    logger.debug("Error no retries left!");
                    request.setStatus(STATUS.ERROR);
                    request.setExecutions(request.getExecutions() + 1);

                    commandService.execute(new MergeObjectCommand(request));

                    if (callbacks != null) {
                        for (CommandCallback handler : callbacks) {
                            handler.onCommandError(ctx, e);
                        }
                    }

                }

            }
        }
    } catch (Exception e) {
        logger.warn("Unexpected error while processin executor's job {}", e.getMessage(), e);
    }
}