Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:org.celllife.idart.gui.patient.AddPatient.java

/**
 * checks if the given date is valid// w w  w  . ja  va2s. c o  m
 * 
 * @param strDay
 *            String
 * @param strMonth
 *            String
 * @param strYear
 *            String
 * @return true if the date is valid else false
 */
public boolean dateOkay(String strDay, String strMonth, String strYear) {

    boolean result = false;

    try {

        int day = Integer.parseInt(strDay);

        // check the year
        if (strYear.length() != 4)
            return result;
        int year = Integer.parseInt(strYear);

        // get the int value for the string month (e.g. January)
        // int month = Integer.parseInt(strMonth);
        int month = -1;
        for (int i = 0; i < cmbDOBMonth.getItemCount(); i++) {
            if (strMonth.equals(cmbDOBMonth.getItem(i))) {
                month = i;
            }
        }

        switch (month) {
        case -1:
            result = false;
            break;
        case Calendar.FEBRUARY:
            if (day <= 29) {
                GregorianCalendar greg = new GregorianCalendar();
                if (day == 29 & greg.isLeapYear(year)) {
                    result = true;
                } else {
                    if (day == 29) {
                        result = false;
                    } else {
                        result = true;
                    }
                }
            } else {
                result = false;
            }
            break;
        case Calendar.JANUARY | Calendar.MARCH | Calendar.MAY | Calendar.JULY | Calendar.AUGUST
                | Calendar.OCTOBER | Calendar.DECEMBER:
            if (day <= 31) {
                result = true;
            } else {
                result = false;
            }
            break;
        default:
            result = true;
            break;
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }

    return result;

}

From source file:com.grazerss.EntryManager.java

public void setMostRecentArticleHash(final String hash) {
    try {/*from   w w w.ja v a 2  s  .  c om*/
        singleValueStore.putString("current_article_hash", hash);
    } catch (RuntimeException re) {
        re.printStackTrace();
    }
}

From source file:com.amazon.kinesis.streaming.agent.Agent.java

@Override
protected void shutDown() throws Exception {
    logger.info("{}: Shutting down...", serviceName());
    Stopwatch shutdownTimer = Stopwatch.createStarted();
    try {/*from  w  w w .  j a  v  a 2  s . c  o m*/
        synchronized (lock) {
            // Stopping all tailers
            for (FileFlow<?> flow : agentContext.flows()) {
                flow.getTailer().stopAsync();
            }
            metricsEmitter.stopAsync();
            heartbeat.stopAsync();
            sendingExecutor.shutdown(); // no more tasks are accepted, but current tasks will try to finish
            // Waiting for them to finish up... this should take less than agentContext.shutdownTimeMillis() (see AsyncPublisher.getShutdownTimeMillis())
            for (FileFlow<?> flow : agentContext.flows()) {
                try {
                    flow.getTailer().awaitTerminated();
                } catch (RuntimeException e) {
                    logger.warn("{}: Error while waiting for tailer {} to stop during shutdown.", serviceName(),
                            flow.getTailer(), e);
                }
            }
        }
        // Shutdown executor
        try {
            List<Runnable> tasks = sendingExecutor.shutdownNow();
            logger.debug("{}: There were {} tasks that were not started due to shutdown.", serviceName(),
                    tasks.size());
            long remaining = agentContext.shutdownTimeoutMillis()
                    - shutdownTimer.elapsed(TimeUnit.MILLISECONDS);
            if (remaining > 0) {
                logger.debug("{}: Waiting up to {} ms for any executing tasks to finish.", serviceName(),
                        remaining);
                try {
                    if (!sendingExecutor.awaitTermination(remaining, TimeUnit.MILLISECONDS)) {
                        logger.info("{}: Not all executing send tasks finished cleanly by shutdown.",
                                serviceName());
                    }
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    logger.debug("{}: Interrupted while waiting for executor to shutdown.", serviceName());
                }
            }
        } catch (Exception e) {
            logger.warn("{}: Error while waiting for executor service to stop during shutdown.", serviceName(),
                    e);
        }
        // Shutdown heartbeats
        try {
            heartbeat.awaitTerminated();
        } catch (Exception e) {
            logger.warn("{}: Error while waiting for heartbeat service to stop during shutdown.", serviceName(),
                    e);
        }
    } catch (Exception e) {
        String msg = String.format("%s: Unhandled exception during shutdown.", serviceName());
        try { // We don't know if logging is still working
            logger.error(msg, e);
        } finally {
            System.err.println(msg);
            e.printStackTrace();
        }
    } finally {
        uptime.stop();
        // Cleanly close the checkpoint store
        checkpoints.close();
        // Print final message
        String msg = String.format("%s: Shut down completed in %d ms. Uptime: %d ms", serviceName(),
                shutdownTimer.elapsed(TimeUnit.MILLISECONDS), uptime.elapsed(TimeUnit.MILLISECONDS));
        try { // We don't know if logging is still working
            logger.info(msg);
        } catch (Exception e) {
            System.err.println(msg);
            e.printStackTrace();
        }
    }
}

From source file:net.cbtltd.rest.AbstractReservation.java

protected static synchronized ReservationResponse createInquiredReservation(String pos, String productId,
        String fromDate, String toDate, String notes, Integer adult, Integer child, // reservation fields
        String emailAddress, String familyName, String firstName, String phoneNumber) { // customer fields
    SqlSession sqlSession = RazorServer.openSession();
    ReservationResponse response = new ReservationResponse();
    Party channelPartnerParty = null;//from  ww  w  . ja  va 2 s  .c o  m
    Party propertyManager = null;
    Product product = null;
    Reservation reservation = null;
    PropertyManagerInfo propertyManagerInfo = null;
    PaymentTransaction paymentTransaction = null;
    boolean successful = false;
    try {
        channelPartnerParty = JSONService.getParty(sqlSession, pos);
        if (channelPartnerParty == null) {
            throw new ServiceException(Error.reservation_agentid);
        }
        product = sqlSession.getMapper(ProductMapper.class).read(productId);
        propertyManager = sqlSession.getMapper(PartyMapper.class).read(product.getSupplierid());
        propertyManagerInfo = sqlSession.getMapper(PropertyManagerInfoMapper.class)
                .readbypmid(Integer.valueOf(product.getSupplierid()));
        Party customer = processCustomer(sqlSession, emailAddress, familyName, firstName, product, phoneNumber,
                channelPartnerParty, product.getSupplierid(), channelPartnerParty, null, null, null, null, null,
                null);
        reservation = PaymentHelper.prepareReservation(channelPartnerParty, customer, product,
                propertyManagerInfo, fromDate, toDate, notes, productId, adult, child);
        reservation.setState(Reservation.State.Cancelled.name());
        sqlSession.getMapper(ReservationMapper.class).create(reservation);
        if (product.getInquireState().equals(Product.SEND_EMAIL)) {
            EmailService.inquiredReservationForManager(sqlSession, reservation);
            EmailService.inquiredReservationForRenter(sqlSession, reservation);
            successful = true;
        } else if (product.getInquireState().equals(Product.USE_API)) {
            PartnerService.inquireReservation(sqlSession, reservation);
            successful = true;
        } else {
            throw new ServiceException(Error.inquiry_state);
        }

        Map<String, String> result = new HashMap<String, String>();
        result.put(GatewayHandler.STATE, GatewayHandler.INQUIRED);
        Integer agentId = channelPartnerParty == null ? null : Integer.valueOf(channelPartnerParty.getId());
        paymentTransaction = PaymentHelper.prepareInquiryTransaction(reservation, product, agentId);
        reservation.setState(Reservation.State.Inquiry.name());
        sqlSession.getMapper(ReservationMapper.class).update(reservation);
        sqlSession.commit();
        response.setPropertyAddress(ReservationService.getPropertyLocation(sqlSession, product));
        response.setPropertyName(product.getName());
        response.setPropertyManagerEmail(propertyManager.getEmailaddress());
        response.setReservationInfo(new ReservationInfo(reservation));
    } catch (RuntimeException x) {
        x.printStackTrace();
        response.setErrorMessage(x.getMessage());
        LOG.error(x.getMessage());
    } catch (Exception x) {
        if (!successful) {
            Integer id = channelPartnerParty == null ? null : Integer.valueOf(channelPartnerParty.getId());
            Map<String, String> result = new HashMap<String, String>();
            result.put(GatewayHandler.STATE, GatewayHandler.FAILED);
            paymentTransaction = PaymentHelper.prepareInquiryTransaction(reservation, product, id);
        }
    } finally {
        if (paymentTransaction != null) {
            sqlSession.getMapper(PaymentTransactionMapper.class).create(paymentTransaction);
            sqlSession.commit();
        }
        sqlSession.close();
    }
    return response;
}

From source file:au.org.theark.lims.web.component.biospecimen.batchaliquot.form.BatchAliquotBiospecimenForm.java

/**
 * /* ww w . j  a va2s  .com*/
 * @return the listEditor of Biospecimens to aliquot
 */
public AbstractListEditor<Biospecimen> buildListEditor() {
    listEditor = new AbstractListEditor<Biospecimen>("aliquots",
            new PropertyModel(getModelObject(), "aliquots")) {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("serial")
        @Override
        protected void onPopulateItem(final ListItem<Biospecimen> item) {
            item.setOutputMarkupId(true);

            Biospecimen parentBiospecimen = BatchAliquotBiospecimenForm.this.getModelObject()
                    .getParentBiospecimen();
            try {
                PropertyUtils.copyProperties(item.getModelObject(), parentBiospecimen);
            } catch (IllegalAccessException e1) {
                log.error(e1.getMessage());
            } catch (InvocationTargetException e1) {
                log.error(e1.getMessage());
            } catch (NoSuchMethodException e1) {
                log.error(e1.getMessage());
            }

            if (copyBiospecimen) {
                item.getModelObject().setParent(parentBiospecimen);
                item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid());
                item.getModelObject().setQuantity(biospecimenToCopy.getQuantity());
                item.getModelObject().setTreatmentType(biospecimenToCopy.getTreatmentType());
                item.getModelObject().setConcentration(biospecimenToCopy.getConcentration());
            } else {
                item.getModelObject().setParent(parentBiospecimen);
                item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid());
                item.getModelObject().setQuantity(null);
                item.getModelObject().setConcentration(null);
            }

            biospecimenUidTxtFld = new TextField<String>("biospecimenUid",
                    new PropertyModel(item.getModelObject(), "biospecimenUid"));
            if (parentBiospecimen.getStudy().getAutoGenerateBiospecimenUid()) {
                biospecimenUidTxtFld.setEnabled(false);
                biospecimenUidTxtFld.setModelObject(Constants.AUTO_GENERATED);
            } else {
                biospecimenUidTxtFld.setEnabled(true);
                biospecimenUidTxtFld.setModelObject(null);
            }

            quantityTxtFld = new TextField<Double>("quantity",
                    new PropertyModel(item.getModelObject(), "quantity")) {
                private static final long serialVersionUID = 1L;

                @Override
                public <C> IConverter<C> getConverter(Class<C> type) {
                    DoubleConverter doubleConverter = new DoubleConverter();
                    NumberFormat numberFormat = NumberFormat.getInstance();
                    numberFormat.setMinimumFractionDigits(1);
                    doubleConverter.setNumberFormat(getLocale(), numberFormat);
                    return (IConverter<C>) doubleConverter;
                }
            };

            initTreatmentTypeDdc(item);
            concentrationTxtFld = new TextField<Number>("concentration",
                    new PropertyModel(item.getModelObject(), "concentration"));

            item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    if (!item.getModelObject().getStudy().getAutoGenerateBiospecimenUid()) {
                        // Check BiospecimenUID is unique
                        String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null
                                ? getComponent().getDefaultModelObject().toString()
                                : new String());
                        Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid,
                                item.getModelObject().getStudy());
                        if (biospecimen != null && biospecimen.getId() != null) {
                            error("Biospecimen UID must be unique. Please try again.");
                            target.focusComponent(getComponent());
                        }
                    }
                    target.add(feedbackPanel);
                    biospecimenToCopy.setBiospecimenUid(getComponent().getDefaultModelObject().toString());
                }
            }));

            item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    if (!totalQuantityLessThanParentQuantity()) {
                        target.focusComponent(getComponent());
                    }
                    target.add(feedbackPanel);
                    biospecimenToCopy.setQuantity((Double) getComponent().getDefaultModelObject());
                    item.getModelObject().setQuantity((Double) getComponent().getDefaultModelObject());
                }

                @Override
                protected void onError(AjaxRequestTarget target, RuntimeException e) {
                    target.add(feedbackPanel);
                }
            }));
            item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    biospecimenToCopy.setTreatmentType((TreatmentType) getComponent().getDefaultModelObject());
                    item.getModelObject()
                            .setTreatmentType((TreatmentType) getComponent().getDefaultModelObject());
                }
            }));
            item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    biospecimenToCopy.setConcentration((Double) getComponent().getDefaultModelObject());
                    item.getModelObject().setConcentration((Double) getComponent().getDefaultModelObject());
                }
            }));

            // Copy button allows entire row details to be copied
            item.add(new AjaxEditorButton(Constants.COPY) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(feedbackPanel);
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    Biospecimen biospecimen = new Biospecimen();
                    copyBiospecimen = true;
                    try {
                        PropertyUtils.copyProperties(biospecimen, getItem().getModelObject());
                        PropertyUtils.copyProperties(biospecimenToCopy, getItem().getModelObject());
                        listEditor.addItem(biospecimen);
                        target.add(form);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    }
                }
            }.setDefaultFormProcessing(false));

            item.add(new AjaxEditorButton(Constants.DELETE) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(feedbackPanel);
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    listEditor.removeItem(item);
                    target.add(form);
                }
            }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }

    };
    return listEditor;
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

private String[] getAvailableFeatureCamera() {
    Camera camera = Camera.open();//  w  w  w.j a  va  2s .co m
    if (camera != null) {
        try {
            android.hardware.Camera.Parameters parameters = camera.getParameters();
            List<String> values = parameters.getSupportedFocusModes();
            /*                List<String> valuessupport = new ArrayList<String>();
                    
                    
                            for (int i = 0; i < values.size(); i++) {
            String strSize = String.valueOf(i) + " : "
                    + String.valueOf(values.get(i).height)
                    + " x "
                    + String.valueOf(values.get(i).width);
            valuessupport.add(strSize);
                            }
                            camera.release();
                            Log.i("#######################################", String.valueOf(valuessupport));*/
            String[] stringList = values.toArray(new String[values.size()]);
            return stringList;
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    return null;
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

private String[] getSupportedOtherCamera(int cam) {
    Camera camera = Camera.open(cam);//from  ww w  . j  a  v  a 2 s . com
    if (camera != null) {
        try {
            String[] stringList = new String[7];
            android.hardware.Camera.Parameters parameters = camera.getParameters();
            String values = "Focus mode: " + parameters.getFocusMode();
            stringList[0] = values;
            values = "Max Num Focus Areas: " + parameters.getMaxNumFocusAreas();
            stringList[1] = values;
            values = "Whitebalance Values: " + parameters.getSupportedWhiteBalance();
            stringList[2] = values;
            values = "Scene mode Values: " + parameters.getSupportedSceneModes();
            stringList[3] = values;
            values = "Effects Values: " + parameters.getSupportedColorEffects();
            stringList[4] = values;
            values = "Stabilization Video: " + parameters.getVideoStabilization();
            stringList[4] = values;
            values = "Quality JPEG: " + parameters.getJpegQuality();
            stringList[5] = values;
            values = "Quality Thumbnail: " + parameters.getJpegThumbnailQuality();
            stringList[6] = values;
            camera.release();
            return stringList;
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    return null;
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

private String[] getSupportedPreviewSizesVideo(int cam) {
    float mp = 0, temp, height, width;
    Camera camera = Camera.open(cam);/*from  www.ja va  2 s  .  co  m*/
    if (camera != null) {
        try {
            android.hardware.Camera.Parameters parameters = camera.getParameters();
            List<Camera.Size> values = parameters.getSupportedVideoSizes();
            List<String> valuessupport = new ArrayList<String>();

            for (int i = 0; i < values.size(); i++) {
                String strSize = String.valueOf(i) + " : " + String.valueOf(values.get(i).height) + " x "
                        + String.valueOf(values.get(i).width);
                valuessupport.add(strSize);
                if (i == 0) {
                    height = Float.parseFloat(String.valueOf(values.get(i).height));
                    width = Float.parseFloat(String.valueOf(values.get(i).width));
                    temp = ((height * width) / 1024000);
                    mp = temp;

                } else {
                    height = Float.parseFloat(String.valueOf(values.get(i).height));
                    width = Float.parseFloat(String.valueOf(values.get(i).width));
                    temp = ((height * width) / 1024000);
                    if (temp > mp) {
                        mp = temp;
                    }
                    if (i == values.size() - 1) {
                        //valuessupport.add(String.valueOf(mp)+" Megapixels");
                    }
                }
            }
            camera.release();
            Log.i("#######################################", String.valueOf(valuessupport));
            String[] stringList = valuessupport.toArray(new String[valuessupport.size()]);
            return stringList;
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    return null;
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

@TargetApi(Build.VERSION_CODES.ECLAIR)
private String[] getSupportedPreviewSizes(int cam) {
    float mp = 0, temp, height, width;
    Camera camera = Camera.open(cam);/*from  www  . j  a v a2  s.  co  m*/
    if (camera != null) {
        try {
            android.hardware.Camera.Parameters parameters = camera.getParameters();
            List<Camera.Size> values = parameters.getSupportedPictureSizes();
            List<String> valuessupport = new ArrayList<String>();

            for (int i = 0; i < values.size(); i++) {
                String strSize = String.valueOf(i) + " : " + String.valueOf(values.get(i).height) + " x "
                        + String.valueOf(values.get(i).width);
                valuessupport.add(strSize);
                if (i == 0) {
                    height = Float.parseFloat(String.valueOf(values.get(i).height));
                    width = Float.parseFloat(String.valueOf(values.get(i).width));
                    temp = ((height * width) / 1024000);
                    mp = temp;

                } else {
                    height = Float.parseFloat(String.valueOf(values.get(i).height));
                    width = Float.parseFloat(String.valueOf(values.get(i).width));
                    temp = ((height * width) / 1024000);
                    if (temp > mp) {
                        mp = temp;
                    }
                    if (i == values.size() - 1) {
                        valuessupport.add(String.valueOf(mp) + " Megapixels");
                    }
                }
            }
            camera.release();
            Log.i("#######################################", String.valueOf(valuessupport));
            String[] stringList = valuessupport.toArray(new String[valuessupport.size()]);
            return stringList;
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    return null;
}

From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean.java

public void setResponseId(String presponseId) {
    try {/*from  w  w  w. ja v a 2 s  . co m*/
        responseId = presponseId;

        if (selectionArray != null && presponseId != null && !presponseId.trim().equals("")) {
            Iterator iter = selectionArray.iterator();
            while (iter.hasNext()) {
                SelectionBean bean = (SelectionBean) iter.next(); // this
                // line
                // will
                // throw
                // ClassCastException
                // for
                // True/False.

                if (bean.getAnswer().getId().toString().equals(presponseId)) {
                    bean.setResponse(true);
                } else {
                    bean.setResponse(false);
                }
            }
        }
        return;
    } catch (RuntimeException e) {
        // True/false
        log.debug("ClassCastException is okay, the question might be true/false. ");
    }

    try {
        Iterator<ItemGradingData> iter = getItemGradingDataArray().iterator();
        if (!iter.hasNext() && (presponseId == null || presponseId.equals(""))) {
            return;
        }
        ItemGradingData data = null;
        if (iter.hasNext()) {
            data = iter.next();
        } else {
            data = new ItemGradingData();
            data.setPublishedItemId(itemData.getItemId());
            ItemTextIfc itemText = (ItemTextIfc) itemData.getItemTextSet().toArray()[0];
            data.setPublishedItemTextId(itemText.getId());
            List<ItemGradingData> items = new ArrayList<ItemGradingData>();
            items.add(data);
            setItemGradingDataArray(items);
        }
        Iterator<AnswerIfc> iterA = ((ItemTextIfc) itemData.getItemTextSet().toArray()[0]).getAnswerSet()
                .iterator();
        while (iterA.hasNext()) {
            AnswerIfc answer = iterA.next();
            if (answer.getId().toString().equals(responseId)) {
                data.setPublishedAnswerId(answer.getId());
                break;
            }
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
}