Example usage for java.lang IllegalAccessException printStackTrace

List of usage examples for java.lang IllegalAccessException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalAccessException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.fao.fenix.wds.web.rest.faostat.FAOSTATExporter.java

@POST
@Path("/streamexcel")
public Response streamExcel(final @FormParam("datasource_WQ") String datasource,
        final @FormParam("json_WQ") String json, final @FormParam("cssFilename_WQ") String cssFilename,
        final @FormParam("valueIndex_WQ") String valueIndex,
        final @FormParam("thousandSeparator_WQ") String thousandSeparator,
        final @FormParam("decimalSeparator_WQ") String decimalSeparator,
        final @FormParam("decimalNumbers_WQ") String decimalNumbers, final @FormParam("quote_WQ") String quote,
        final @FormParam("title_WQ") String title, final @FormParam("subtitle_WQ") String subtitle) {

    // Initiate the stream
    StreamingOutput stream = new StreamingOutput() {

        @Override/*from   w  w w .  j a v  a2 s  .  c o m*/
        public void write(OutputStream os) throws IOException, WebApplicationException {

            // compute result
            Gson g = new Gson();
            SQLBean sql = g.fromJson(json, SQLBean.class);
            DatasourceBean db = datasourcePool.getDatasource(datasource.toUpperCase());
            Writer writer = new BufferedWriter(new OutputStreamWriter(os));

            // compute result
            JDBCIterable it = new JDBCIterable();

            try {

                // alter the query to switch from LIMIT to TOP
                if (datasource.toUpperCase().startsWith("FAOSTAT"))
                    sql.setQuery(replaceLimitWithTop(sql));

                it.query(db, Bean2SQL.convert(sql).toString());

            } catch (IllegalAccessException e) {
                e.printStackTrace();
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'streamExcel' thrown an error: " + e.getMessage()));
            } catch (InstantiationException e) {
                e.printStackTrace();
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'streamExcel' thrown an error: " + e.getMessage()));
            } catch (SQLException e) {
                e.printStackTrace();
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'streamExcel' thrown an error: " + e.getMessage()));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'streamExcel' thrown an error: " + e.getMessage()));
            } catch (Exception e) {
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'getDomains' thrown an error: " + e.getMessage()));
            }

            writer.write("\ufeff");
            writer.write("<table>");

            // add column names
            List<String> cols = it.getColumnNames();
            writer.write("<tr>");
            for (int i = 0; i < cols.size(); i++) {
                writer.write("<td>");
                writer.write(cols.get(i));
                writer.write("</td>");
            }
            writer.write("</tr>");

            // write the result of the query
            while (it.hasNext()) {
                List<String> l = it.next();
                writer.write("<tr>");
                for (int i = 0; i < l.size(); i++) {
                    writer.write("<td>");
                    writer.write(l.get(i));
                    writer.write("</td>");
                }
                writer.write("</tr>");
            }

            // add metadata
            writer.write("<tr><td>&nbsp;</td></tr>");
            writer.write("<tr>");
            writer.write("<td>");
            writer.write(createMetadata());
            writer.write("<td>");
            writer.write("</tr>");

            writer.write("</table>");

            // Convert and write the output on the stream
            writer.flush();
            writer.close();

        }

    };

    // Wrap result
    ResponseBuilder builder = Response.ok(stream);
    builder.header("Content-Disposition", "attachment; filename=" + UUID.randomUUID().toString() + ".xls");

    // Stream Excel
    return builder.build();

}

From source file:nonjsp.application.BuildComponentFromTagImpl.java

public void applyAttributesToComponentInstance(UIComponent child, Attributes attrs) {
    int attrLen, i = 0;
    String attrName, attrValue;/*w  w w  . j a  v a2  s  . c  o m*/

    attrLen = attrs.getLength();
    for (i = 0; i < attrLen; i++) {
        attrName = mapAttrNameToPropertyName(attrs.getLocalName(i));
        attrValue = attrs.getValue(i);

        // First, try to set it as a bean property
        try {
            PropertyUtils.setNestedProperty(child, attrName, attrValue);
        } catch (NoSuchMethodException e) {
            // If that doesn't work, see if it requires special
            // treatment
            try {
                if (attrRequiresSpecialTreatment(attrName)) {
                    handleSpecialAttr(child, attrName, attrValue);
                } else {
                    // If that doesn't work, this will.
                    child.getAttributes().put(attrName, attrValue);
                }
            } catch (IllegalAccessException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (IllegalArgumentException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (InvocationTargetException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (NoSuchMethodException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            }
        } catch (IllegalArgumentException e) {
            try {
                if (attrRequiresSpecialTreatment(attrName)) {
                    handleSpecialAttr(child, attrName, attrValue);
                } else {
                    // If that doesn't work, this will.
                    child.getAttributes().put(attrName, attrValue);
                }
            } catch (IllegalAccessException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (IllegalArgumentException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (InvocationTargetException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (NoSuchMethodException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            }
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            log.trace(e.getMessage());
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            log.trace(e.getMessage());
        }
    }

    // cleanup: make sure we have the necessary required attributes
    if (child.getId() == null) {
        String gId = "foo" + Util.generateId();
        child.setId(gId);
    }

}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.experiments.CopyNumberVariationExperimentModel.java

@NotifyChange({ "currentSample", "samples" })
@Command/*from w  ww . j av a 2s.c  o m*/
public void editSample(@BindingParam("sample") Sample sample) {
    this.edit = true;
    this.currentSample = sample;
    this.currentTmpSample = new Sample();
    try {
        BeanUtils.copyProperties(this.currentTmpSample, this.currentSample);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}

From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.experiments.CopyNumberVariationExperimentModel.java

@NotifyChange({ "currentKnownIndels" })
@Command//w  ww.  j av  a  2 s  .com
public void editKnownIndels(@BindingParam("knownIndels") KnownIndels knownIndels) {
    this.editKnownIndels = true;
    this.currentKnownIndels = knownIndels;
    this.currentTmpKnownIndels = new KnownIndels();
    try {
        BeanUtils.copyProperties(this.currentTmpKnownIndels, this.currentKnownIndels);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}

From source file:gov.nih.nci.caarray.plugins.agilent.AgilentRawTextDataHandlerTest.java

private void checkColumnLength(HybridizationData hybridizationData,
        AgilentTextQuantitationType quantitationType, int expectedColumnLength) {
    try {/*from   w  w  w  .ja  v  a 2s  .  c o m*/
        final AbstractDataColumn column = hybridizationData.getColumn(quantitationType);
        assertNotNull(column);
        final Object array = PropertyUtils.getProperty(column, "values");
        assertEquals(expectedColumnLength, Array.getLength(array));
    } catch (final IllegalAccessException ex) {
        ex.printStackTrace();
        fail(ex.toString());
    } catch (final InvocationTargetException ex) {
        ex.printStackTrace();
        fail(ex.toString());
    } catch (final NoSuchMethodException ex) {
        ex.printStackTrace();
        fail(ex.toString());
    }
}

From source file:org.openremote.beehive.api.service.impl.ModelServiceImpl.java

public ModelDTO loadModelById(long modelId) {
    ModelDTO modelDTO = new ModelDTO();
    try {/*ww  w .  ja v a  2  s. c o  m*/
        BeanUtils.copyProperties(modelDTO, loadById(modelId));
    } catch (IllegalAccessException e) {
        logger.error("", e);
    } catch (InvocationTargetException e) {
        // TODO handle exception
        e.printStackTrace();
    }
    return modelDTO;
}

From source file:org.kuali.kfs.module.tem.service.impl.AccountingDistributionServiceImpl.java

@SuppressWarnings("deprecation")
@Override/*  w  w  w.j a  v a  2s. c  om*/
public List<TemSourceAccountingLine> distributionToSouceAccountingLines(
        List<TemDistributionAccountingLine> distributionAccountingLines,
        List<AccountingDistribution> accountingDistributionList, KualiDecimal sourceAccountingLinesTotal,
        KualiDecimal expenseLimit) {
    List<TemSourceAccountingLine> sourceAccountingList = new ArrayList<TemSourceAccountingLine>();
    Map<String, AccountingDistribution> distributionMap = new HashMap<String, AccountingDistribution>();
    KualiDecimal total = KualiDecimal.ZERO;
    int distributionTargetCount = 0;
    boolean useExpenseLimit = false;
    for (AccountingDistribution accountDistribution : accountingDistributionList) {
        if (accountDistribution.getSelected()) {
            total = total.add(accountDistribution.getRemainingAmount());
            distributionTargetCount += 1;
        }
    }

    if (expenseLimit != null && expenseLimit.isPositive()) {
        KualiDecimal expenseLimitTotal = new KualiDecimal(expenseLimit.bigDecimalValue());
        // do we have any accounting line amount to subtract from the expense limit?
        if (sourceAccountingLinesTotal != null && sourceAccountingLinesTotal.isGreaterThan(KualiDecimal.ZERO)) {
            expenseLimitTotal = expenseLimitTotal.subtract(sourceAccountingLinesTotal);
        }
        if (expenseLimitTotal.isLessThan(total)) {
            total = expenseLimitTotal;
            useExpenseLimit = true;
        }
    }

    if (total.isGreaterThan(KualiDecimal.ZERO)) {
        for (AccountingDistribution accountingDistribution : accountingDistributionList) {
            List<TemSourceAccountingLine> tempSourceAccountingList = new ArrayList<TemSourceAccountingLine>();
            if (accountingDistribution.getSelected()) {
                for (TemDistributionAccountingLine accountingLine : distributionAccountingLines) {
                    TemSourceAccountingLine newLine = new TemSourceAccountingLine();
                    try {
                        BeanUtils.copyProperties(newLine, accountingLine);
                    } catch (IllegalAccessException ex) {
                        ex.printStackTrace();
                    } catch (InvocationTargetException ex) {
                        ex.printStackTrace();
                    }
                    BigDecimal distributionAmount = (distributionTargetCount > 1)
                            ? accountingDistribution.getRemainingAmount().bigDecimalValue()
                            : total.bigDecimalValue();
                    BigDecimal product = accountingLine.getAccountLinePercent().multiply(distributionAmount);
                    product = product.divide(new BigDecimal(100), 5, RoundingMode.HALF_UP);
                    BigDecimal lineAmount = product.divide(total.bigDecimalValue(), 5, RoundingMode.HALF_UP);

                    newLine.setAmount(new KualiDecimal(product));
                    newLine.setCardType(accountingDistribution.getCardType());
                    Map<String, Object> fieldValues = new HashMap<String, Object>();
                    fieldValues.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE,
                            accountingDistribution.getObjectCode());
                    fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
                            newLine.getChartOfAccountsCode());
                    fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
                            SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear());
                    ObjectCode objCode = getBusinessObjectService().findByPrimaryKey(ObjectCode.class,
                            fieldValues);
                    newLine.setObjectCode(objCode);
                    newLine.setFinancialObjectCode(accountingDistribution.getObjectCode());
                    tempSourceAccountingList.add(newLine);
                }
                if (useExpenseLimit) {
                    sourceAccountingList.addAll(tempSourceAccountingList); //we just adjusted the accounting lines for the expense...let's not readjust
                } else {
                    sourceAccountingList.addAll(adjustValues(tempSourceAccountingList,
                            accountingDistribution.getRemainingAmount()));
                }
            }
        }
    }
    return sourceAccountingList;
}

From source file:ubic.gemma.core.loader.expression.arrayDesign.ArrayDesignSequenceAlignmentServiceImpl.java

/**
 * @param brs, assumed to be from alignments to the genome for the array design (that is, we don't consider aligning
 *             mouse to human)/*from w w  w.j  a v a  2  s .c om*/
 */
@SuppressWarnings("unchecked")
private Collection<BlatResult> persistBlatResults(Collection<BlatResult> brs) {

    Collection<Integer> seen = new HashSet<>();
    int duplicates = 0;
    for (BlatResult br : brs) {

        Integer hash = ProbeMapUtils.hashBlatResult(br);
        if (seen.contains(hash)) {
            duplicates++;
            continue;
        }
        seen.add(hash);

        assert br.getQuerySequence() != null;
        assert br.getQuerySequence().getName() != null;
        Taxon taxon = br.getQuerySequence().getTaxon();
        assert taxon != null;

        try {
            FieldUtils.writeField(br.getTargetChromosome(), "taxon", taxon, true);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        br.getTargetChromosome().getSequence().setTaxon(taxon);

        PhysicalLocation pl = br.getTargetAlignedRegion();
        if (pl == null) {
            pl = PhysicalLocation.Factory.newInstance();
            pl.setChromosome(br.getTargetChromosome());
            pl.setNucleotide(br.getTargetStart());
            assert br.getTargetEnd() != null && br.getTargetStart() != null;
            pl.setNucleotideLength(br.getTargetEnd().intValue() - br.getTargetStart().intValue());
            pl.setStrand(br.getStrand());
            br.setTargetAlignedRegion(pl);
            pl.setBin(SequenceBinUtils.binFromRange(br.getTargetStart().intValue(),
                    br.getTargetEnd().intValue()));
        }

    }

    if (duplicates > 0) {
        ArrayDesignSequenceAlignmentServiceImpl.log.info(duplicates + " duplicate BLAT hits skipped");
    }

    return (Collection<BlatResult>) persisterHelper.persist(brs);
}

From source file:com.project.implementation.ReservationImplementation.java

public String makeReservation(GuestDTO guestDTO, Integer no_of_rooms_Int, Date checkin_date,
        Date checkout_date) {// w  w  w  .  ja  v a2s.c  o  m
    Integer guestID = 0, guestCount;
    String room_selected = guestDTO.getRoom_no_selected();
    Guest guestObject = new Guest();

    try {
        org.apache.commons.beanutils.BeanUtils.copyProperties(guestObject, guestDTO);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }

    //check email id if exist
    guestID = guestDAO.checkGuestExist(guestDTO.getGuest_email(), guestDTO.getLicense_no());
    System.out.println("guestID: " + guestID);
    //if email id, license exist
    if (!(guestID == 0)) {
        System.out.println("value = ");
        //update details
        guestCount = guestDAO.updateUserDetails(guestID, guestDTO.getGuest_name(), guestDTO.getStreet(),
                guestDTO.getCity(), guestDTO.getState(), guestDTO.getZip());
        if (guestCount != 0)
            guestObject = guestDAO.getGuestRecord(guestID);
    } else {
        guestObject = guestDAO.save(guestObject);
    }

    String randomDate = FastDateFormat.getInstance("dd-MM-yyyy").format(System.currentTimeMillis());

    UUID id = UUID.randomUUID();
    String token_no = String.valueOf(id);
    //System.out.println(sensor_id);

    // String token_no = guestObject.getLicense_no() + guestObject.getGuest_id()+randomDate;

    java.util.Date todayUtilDate = Calendar.getInstance().getTime();//2015-12-05
    java.sql.Date todaySqlDate = new java.sql.Date(todayUtilDate.getTime());

    Reservation reservationObject = new Reservation();
    //        reservationObject.setReservation_id(0);
    reservationObject.setGuest_id(guestObject.getGuest_id());
    reservationObject.setReservation_token(token_no);
    reservationObject.setReservation_date(todaySqlDate);
    reservationObject.setReservation_status(ReservationStatus.R);
    reservationObject = reservationDAO.save(reservationObject);
    // Integer reservation_id = reservationObject.getReservation_id();

    String[] resultStringArray = guestDTO.getRoom_no_selected().split(",");
    ArrayList<Integer> arrRooms = new ArrayList<Integer>();
    for (String str : resultStringArray) {
        arrRooms.add(Integer.parseInt(str));
        CheckinRoomMapping checkinRoomMappingObject = new CheckinRoomMapping();
        checkinRoomMappingObject.setReservation(reservationObject);
        checkinRoomMappingObject.setRoom_no(Integer.parseInt(str));
        checkinRoomMappingObject.setCheckin_date(checkin_date);
        checkinRoomMappingObject.setCheckout_date(checkout_date);
        checkinRoomMappingObject.setGuest_count(0);
        checkinRoomMappingObject.setMappingId(0);
        checkinRoomMappingDAO.save(checkinRoomMappingObject);
    }
    //add email code start here

    final String from = "express.minihotel@gmail.com";
    String to = guestObject.getGuest_email();
    String body = "Hello " + guestObject.getGuest_name()
            + ", <br/><br></br>Your reservation has been confirmed.Your reservation ID is <font color='red'><b>"
            + token_no
            + "</b></font>.</br>Please bring the Driving License for verification at the time of Check In.</br><br></br>"
            + "<b>Note:</b>If you want to cancel the reservation, "
            + "please <a href=\'http://52.53.255.195:8080/CmpE275Team07Fall2015TermProject/v1/cancelReservation?reservation_token="
            + token_no + "\'>Click Here</a><br></br>--<i>Express Hotel</i>";
    String subject = "Express Hotel Reservation Confirmation <" + token_no + ">";

    final String password = "Minihotel@2015";
    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "587");
    Session session = Session.getInstance(props, new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(from, password);
        }
    });
    try {
        MimeMessage email = new MimeMessage(session);
        email.setFrom(new InternetAddress(from));
        email.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
        email.setSubject(subject);
        email.setContent(body, "text/html");
        Transport.send(email);

    } catch (MessagingException e) {

        throw new RuntimeException(e);

    }
    //email code end here

    return token_no;
}

From source file:ubic.gemma.core.loader.expression.arrayDesign.ArrayDesignSequenceAlignmentServiceImpl.java

@Override
public Collection<BlatResult> processArrayDesign(ArrayDesign ad, Taxon taxon,
        Collection<BlatResult> rawBlatResults) {

    ArrayDesignSequenceAlignmentServiceImpl.log.info("Looking for old results to remove...");

    ad = arrayDesignService.thaw(ad);//from  www. j  a v a  2 s. c o  m

    arrayDesignService.deleteAlignmentData(ad);
    // Blat file processing can only be run on one taxon at a time
    taxon = this.validateTaxaForBlatFile(ad, taxon);

    Collection<BioSequence> sequencesToBlat = ArrayDesignSequenceAlignmentServiceImpl.getSequences(ad);
    sequencesToBlat = bioSequenceService.thaw(sequencesToBlat);

    // if the blat results were loaded from a file, we have to replace the
    // query sequences with the actual ones
    // attached to the array design. We have to do this by name because the
    // sequence name is what the files contain.
    // Note that if there is ambiguity there will be problems!
    Map<String, BioSequence> seqMap = new HashMap<>();
    for (BioSequence bioSequence : sequencesToBlat) {
        seqMap.put(bioSequence.getName(), bioSequence);
    }

    ExternalDatabase searchedDatabase = ShellDelegatingBlat.getSearchedGenome(taxon);

    Collection<BlatResult> toSkip = new HashSet<>();
    for (BlatResult result : rawBlatResults) {

        /*
         * If the sequences don't have ids, replace them with the actual sequences associated with the array design.
         */
        if (result.getQuerySequence().getId() == null) {
            String querySeqName = result.getQuerySequence().getName();
            BioSequence actualSequence = seqMap.get(querySeqName);
            if (actualSequence == null) {
                ArrayDesignSequenceAlignmentServiceImpl.log
                        .debug("Array design does not contain a sequence with name " + querySeqName);
                toSkip.add(result);
                continue;
            }
            result.setQuerySequence(actualSequence);
        } else {
            result.getQuerySequence().setTaxon(taxon);
        }

        result.setSearchedDatabase(searchedDatabase);
        try {
            FieldUtils.writeField(result.getTargetChromosome(), "taxon", taxon, true);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        result.getTargetChromosome().getSequence().setTaxon(taxon);

    }

    if (toSkip.size() > 0) {
        ArrayDesignSequenceAlignmentServiceImpl.log.warn(
                toSkip.size() + " blat results were for sequences not on " + ad + "; they will be ignored.");
        rawBlatResults.removeAll(toSkip);
    }

    Map<BioSequence, Collection<BlatResult>> goldenPathAlignments = new HashMap<>();
    this.getGoldenPathAlignments(sequencesToBlat, taxon, goldenPathAlignments);
    for (BioSequence sequence : goldenPathAlignments.keySet()) {
        rawBlatResults.addAll(goldenPathAlignments.get(sequence));
    }

    Collection<BlatResult> results = this.persistBlatResults(rawBlatResults);

    arrayDesignReportService.generateArrayDesignReport(ad.getId());

    return results;
}