Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:Controller.UserController.java

@RequestMapping(value = "/SaveSetting", method = RequestMethod.POST)
public String saveSetting(HttpServletRequest request) {
    try {/*  ww  w.  jav  a2s .  c om*/
        int tripperID;
        try {
            tripperID = Integer.parseInt(request.getParameter("tripperID"));
        } catch (NumberFormatException e) {
            tripperID = 0;
        }
        tripperService.saveSetting(tripperID, request.getParameter("settingJson"));
        if (request.getParameter("language") != null) {
            return "redirect:/Tripper/Notification" + "?language=" + request.getParameter("language");
        } else {
            return "redirect:/Tripper/Notification";
        }

    } catch (Exception e) {
        HttpSession session = request.getSession(true);
        String content = "Function: UserController - saveSetting\n" + "***Input***\n" + "tripperID: "
                + request.getAttribute("tripperID") + "\n" + "settingJson: "
                + request.getAttribute("settingJson") + "\n" + "**********\n" + "****Error****\n"
                + e.getMessage() + "\n" + "**********";
        request.setAttribute("errorID", session.getId());
        request.setAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }

}

From source file:controllers.AnyplaceMapping.java

/**
 * Adds a new building to the database/*from  ww  w  .jav  a2s  . co  m*/
 *
 * @return the newly created Building ID is included in the response if success
 */
public static Result buildingAdd() {

    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }

    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::buildingAdd(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "is_published", "name",
            "description", "url", "address", "coordinates_lat", "coordinates_lon", "access_token");

    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }

    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    try {
        Building building;
        try {
            building = new Building(json);
        } catch (NumberFormatException e) {
            return AnyResponseHelper.bad_request("Building coordinates are invalid!");
        }
        //System.out.println(building.toValidCouchJson());
        if (!ProxyDataSource.getIDatasource().addJsonDocument(building.getId(), 0, building.toCouchGeoJSON())) {
            return AnyResponseHelper.bad_request("Building already exists or could not be added!");
        }
        ObjectNode res = JsonUtils.createObjectNode();
        res.put("buid", building.getId());
        return AnyResponseHelper.ok(res, "Successfully added building!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:com.fullmetalgalaxy.server.pm.PMServlet.java

@Override
protected void doPost(HttpServletRequest p_request, HttpServletResponse p_response)
        throws ServletException, IOException {
    ServletFileUpload upload = new ServletFileUpload();
    try {/*from   w  ww .j a  v a2s . c  om*/
        // build message to send
        Properties props = new Properties();
        Session session = Session.getDefaultInstance(props, null);
        MimeMessage msg = new MimeMessage(session);
        msg.setSubject("[FMG] no subject", "text/plain");
        msg.setSender(new InternetAddress("admin@fullmetalgalaxy.com", "FMG Admin"));
        msg.setFrom(new InternetAddress("admin@fullmetalgalaxy.com", "FMG Admin"));
        EbAccount fromAccount = null;

        // Parse the request
        FileItemIterator iter = upload.getItemIterator(p_request);
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            if (item.isFormField()) {
                if ("msg".equalsIgnoreCase(item.getFieldName())) {
                    msg.setContent(Streams.asString(item.openStream(), "UTF-8"), "text/plain");
                }
                if ("subject".equalsIgnoreCase(item.getFieldName())) {
                    msg.setSubject("[FMG] " + Streams.asString(item.openStream(), "UTF-8"), "text/plain");
                }
                if ("toid".equalsIgnoreCase(item.getFieldName())) {
                    EbAccount account = null;
                    try {
                        account = FmgDataStore.dao().get(EbAccount.class,
                                Long.parseLong(Streams.asString(item.openStream(), "UTF-8")));
                    } catch (NumberFormatException e) {
                    }
                    if (account != null) {
                        msg.addRecipient(Message.RecipientType.TO,
                                new InternetAddress(account.getEmail(), account.getPseudo()));
                    }
                }
                if ("fromid".equalsIgnoreCase(item.getFieldName())) {
                    try {
                        fromAccount = FmgDataStore.dao().get(EbAccount.class,
                                Long.parseLong(Streams.asString(item.openStream(), "UTF-8")));
                    } catch (NumberFormatException e) {
                    }
                    if (fromAccount != null) {
                        if (fromAccount.getAuthProvider() == AuthProvider.Google
                                && !fromAccount.isHideEmailToPlayer()) {
                            msg.setFrom(new InternetAddress(fromAccount.getEmail(), fromAccount.getPseudo()));
                        } else {
                            msg.setFrom(
                                    new InternetAddress(fromAccount.getFmgEmail(), fromAccount.getPseudo()));
                        }
                    }
                }
            }
        }

        // msg.addRecipients( Message.RecipientType.BCC, InternetAddress.parse(
        // "archive@fullmetalgalaxy.com" ) );
        Transport.send(msg);

    } catch (Exception e) {
        log.error(e);
        p_response.sendRedirect("/genericmsg.jsp?title=Error&text=" + e.getMessage());
        return;
    }

    p_response.sendRedirect("/genericmsg.jsp?title=Message envoye");
}

From source file:com.sfs.whichdoctor.search.http.PersonInputHandler.java

/**
 * Process the incoming HttpRequest for search parameters.
 *
 * @param request the request//from   w w  w . j  av  a2  s.  co m
 * @param user the user
 *
 * @return the search bean
 */
public final SearchBean process(final HttpServletRequest request, final UserBean user) {

    SearchBean search = personSqlHandler.initiate(user);

    PersonBean searchCriteria = (PersonBean) search.getSearchCriteria();
    PersonBean searchConstraints = (PersonBean) search.getSearchConstraints();

    String firstName = DataFilter.getHtml(request.getParameter("firstName"));
    String lastName = DataFilter.getHtml(request.getParameter("lastName"));
    String strGender = DataFilter.getHtml(request.getParameter("gender"));
    /* Membership type fields */
    String strMINA = DataFilter.getHtml(request.getParameter("minA"));
    String strMINB = DataFilter.getHtml(request.getParameter("minB"));

    String strGUIDList = DataFilter.getHtml(request.getParameter("guidList"));
    String strIncludeGUIDList = DataFilter.getHtml(request.getParameter("includeGUIDList"));
    String strIdentifierList = DataFilter.getHtml(request.getParameter("identifierList"));

    String strTrainingStatus = DataFilter.getHtml(request.getParameter("trainingStatus"));
    String strTrainingStatusDetail = DataFilter.getHtml(request.getParameter("trainingStatusDetail"));
    String strTrainingOrganisation = DataFilter.getHtml(request.getParameter("trainingOrganisation"));
    String strTrainingProgram = DataFilter.getHtml(request.getParameter("trainingProgram"));
    String trainingProgramYearA = DataFilter.getHtml(request.getParameter("trainingProgramYearA"));
    String trainingProgramYearB = DataFilter.getHtml(request.getParameter("trainingProgramYearB"));
    String strSpecialtyStatus = DataFilter.getHtml(request.getParameter("specialtyStatus"));

    String strOrganisation = DataFilter.getHtml(request.getParameter("organisation"));
    String strRegion = DataFilter.getHtml(request.getParameter("region"));
    String strAddressClass = DataFilter.getHtml(request.getParameter("addressClass"));
    String strAddressType = DataFilter.getHtml(request.getParameter("addressType"));
    String strCountry = DataFilter.getHtml(request.getParameter("country"));
    String strCity = DataFilter.getHtml(request.getParameter("city"));
    String strAddressReturnedMail = DataFilter.getHtml(request.getParameter("addressReturnedMail"));
    String strAddressRequestNoMail = DataFilter.getHtml(request.getParameter("addressRequestNoMail"));

    String strEmailType = DataFilter.getHtml(request.getParameter("emailType"));
    String strEmailReturnedMail = DataFilter.getHtml(request.getParameter("emailReturnedMail"));
    String strEmailRequestNoMail = DataFilter.getHtml(request.getParameter("emailRequestNoMail"));
    String strEmailQuestions = DataFilter.getHtml(request.getParameter("emailQuestions"));

    String strClosingBalanceA = DataFilter.getHtml(request.getParameter("closingBalanceA"));
    String strClosingBalanceB = DataFilter.getHtml(request.getParameter("closingBalanceB"));

    String strWorkshopType = DataFilter.getHtml(request.getParameter("workshopType"));
    String strWorkshopAttendance = DataFilter.getHtml(request.getParameter("workshopAttendance"));
    String strWorkshopYear = DataFilter.getHtml(request.getParameter("workshopYear"));

    String strAccreditationA = DataFilter.getHtml(request.getParameter("accreditationA"));
    String strAccreditationB = DataFilter.getHtml(request.getParameter("accreditationB"));
    String strAccreditationTotal = DataFilter.getHtml(request.getParameter("accreditationTotal"));
    String strAccreditationType = DataFilter.getHtml(request.getParameter("accreditationType"));
    String strAccreditationSpecialty = DataFilter.getHtml(request.getParameter("accreditationSpecialty"));

    String strExamType = DataFilter.getHtml(request.getParameter("examType"));
    String strExamStatus = "";
    String strExamStatusLevel = "";
    if (StringUtils.equals(strExamType, "Written Exam")) {
        strExamStatus = DataFilter.getHtml(request.getParameter("writtenExamStatus"));
        strExamStatusLevel = DataFilter.getHtml(request.getParameter("writtenExamStatusLevel"));
    }
    if (StringUtils.equals(strExamType, "Clinical Exam")) {
        strExamStatus = DataFilter.getHtml(request.getParameter("clinicalExamStatus"));
        strExamStatusLevel = DataFilter.getHtml(request.getParameter("clinicalExamStatusLevel"));
    }

    String strExamDateA = DataFilter.getHtml(request.getParameter("examDateA"));
    String strExamDateB = DataFilter.getHtml(request.getParameter("examDateB"));

    String strQualificationType = DataFilter.getHtml(request.getParameter("qualificationType"));
    String strQualificationSubType = DataFilter.getHtml(request.getParameter("qualificationSubType"));
    String strQualificationInstitution = DataFilter.getHtml(request.getParameter("qualificationInstitution"));
    String strQualificationCountry = DataFilter.getHtml(request.getParameter("qualificationCountry"));
    String strGraduatedA = DataFilter.getHtml(request.getParameter("graduatedA"));
    String strGraduatedB = DataFilter.getHtml(request.getParameter("graduatedB"));

    String strRotationGUID = DataFilter.getHtml(request.getParameter("rotationGUID"));

    String strCreatedA = DataFilter.getHtml(request.getParameter("createdA"));
    String strCreatedB = DataFilter.getHtml(request.getParameter("createdB"));
    String strUpdatedA = DataFilter.getHtml(request.getParameter("updatedA"));
    String strUpdatedB = DataFilter.getHtml(request.getParameter("updatedB"));

    // Set first and last name requirements
    if (StringUtils.isNotBlank(firstName)) {
        searchCriteria.setFirstName(firstName.trim());
    }
    if (StringUtils.isNotBlank(lastName)) {
        searchCriteria.setLastName(lastName.trim());
    }
    if (StringUtils.isNotBlank(strGender) && !StringUtils.equals(strGender, "Null")) {
        searchCriteria.setGender(strGender);
    }

    /* Tag searches */
    searchCriteria.setTags(this.setTagArray(request, user));

    // Add MIN number to criteria if successfully parsed to int
    try {
        int criteriaMIN = Integer.parseInt(strMINA);
        searchCriteria.setPersonIdentifier(criteriaMIN);
    } catch (NumberFormatException nfe) {
        dataLogger.debug("Error parsing MIN: " + nfe.getMessage());
    }

    if (StringUtils.isNotBlank(strMINB)) {
        int constraintMIN = 0;
        try {
            constraintMIN = Integer.parseInt(strMINB);
        } catch (NumberFormatException nfe) {
            dataLogger.debug("Error parsing MIN contraint: " + nfe.getMessage());
        }
        if (StringUtils.equals(strMINB, "+")) {
            constraintMIN = MAX_ID;
        }
        if (StringUtils.equals(strMINB, "-")) {
            constraintMIN = -1;
        }
        searchConstraints.setPersonIdentifier(constraintMIN);
    }

    if (StringUtils.isNotBlank(strGUIDList)) {
        // Parse the GUID list string into a collection of strings
        searchCriteria.setGUIDList(DataFilter.parseTextDataToCollection(strGUIDList));
    }

    if (StringUtils.isNotBlank(strIncludeGUIDList)) {
        // Parse the GUID list string into a collection of strings
        searchCriteria.setIncludeGUIDList(DataFilter.parseTextDataToCollection(strIncludeGUIDList));
    }

    if (StringUtils.isNotBlank(strIdentifierList)) {
        // Parse the identifier list string into a collection of strings
        searchCriteria.setIdentifierList(DataFilter.parseTextDataToCollection(strIdentifierList));
    }

    if (strRegion != null) {
        if (strRegion.compareTo("Null") != 0) {
            searchCriteria.setRegion(strRegion);
        }
    }

    // Process the membership parameters
    Collection<MembershipBean> membershipDetailsCriteria = new ArrayList<MembershipBean>();
    Collection<MembershipBean> membershipDetailsConstraints = new ArrayList<MembershipBean>();

    ArrayList<MembershipBean> memDetailsCriteria = (ArrayList<MembershipBean>) searchCriteria
            .getMembershipDetails();

    // Iterate through membership beans
    for (int a = 0; a < memDetailsCriteria.size(); a++) {

        MembershipBean membershipCriteria = memDetailsCriteria.get(a);

        MembershipBean[] result = null;

        if (StringUtils.equalsIgnoreCase(membershipCriteria.getMembershipClass(), "RACP")
                && StringUtils.equalsIgnoreCase(membershipCriteria.getMembershipType(), "")) {

            result = processRACPMembership(request);
        }

        if (StringUtils.equalsIgnoreCase(membershipCriteria.getMembershipClass(), "RACP")
                && StringUtils.equalsIgnoreCase(membershipCriteria.getMembershipType(), "Fellowship Details")) {

            result = processRACPFellowship(request);
        }

        if (StringUtils.equalsIgnoreCase(membershipCriteria.getMembershipClass(), "RACP")
                && StringUtils.equalsIgnoreCase(membershipCriteria.getMembershipType(), "Affiliation")) {

            result = processRACPAffiliation(request);
        }

        if (result != null) {
            MembershipBean criteria = result[0];
            MembershipBean constraints = result[1];

            if (criteria != null && constraints != null) {
                membershipDetailsCriteria.add(criteria);
                membershipDetailsConstraints.add(constraints);
            }
        }
    }
    // Add the membership detail arrays back to the search beans
    searchCriteria.setMembershipDetails(membershipDetailsCriteria);
    searchConstraints.setMembershipDetails(membershipDetailsConstraints);

    /* Check if accreditation was set */
    AccreditationBean accredA = new AccreditationBean();
    AccreditationBean accredB = new AccreditationBean();

    if (StringUtils.isNotBlank(strAccreditationA)) {
        // Value submitted for A
        try {
            accredA.setWeeksCertified(Formatter.getWholeWeeks(Integer.parseInt(strAccreditationA)));
        } catch (NumberFormatException nfe) {
            dataLogger.debug("Error parsing accreditationA: " + nfe.getMessage());
        }
    }
    if (StringUtils.isNotBlank(strAccreditationB)) {
        // Value submitted for B
        try {
            accredB.setWeeksCertified(Formatter.getWholeWeeks(Integer.parseInt(strAccreditationB)));
        } catch (NumberFormatException nfe) {
            dataLogger.debug("Error parsing accreditationB: " + nfe.getMessage());
        }

        if (StringUtils.equals(strAccreditationB, "+")) {
            accredB.setWeeksCertified(MAX_ACCREDITATION);
        }
        if (StringUtils.equals(strAccreditationB, "-")) {
            accredB.setWeeksCertified(-1);
        }
    }

    if (accredB.getWeeksCertified() < accredA.getWeeksCertified()) {
        int tempValue = accredA.getWeeksCertified();
        accredA.setWeeksCertified(accredB.getWeeksCertified());
        accredB.setWeeksCertified(tempValue);
    }
    if (accredB.getWeeksCertified() == 0) {
        accredB.setWeeksCertified(accredA.getWeeksCertified());
    }
    if (accredA.getWeeksCertified() == 0) {
        accredA.setWeeksCertified(accredB.getWeeksCertified());
    }

    if (accredA.getWeeksCertified() != 0) {
        if (strAccreditationTotal != null) {
            accredA.setAbbreviation(strAccreditationTotal);
        }
        if (strAccreditationType != null) {
            if (strAccreditationType.compareTo("Null") != 0) {
                accredA.setAccreditationType(strAccreditationType);
            }
        }
        if (strAccreditationSpecialty != null) {
            if (strAccreditationSpecialty.compareTo("Null") != 0) {
                accredA.setSpecialtyType(strAccreditationSpecialty);
            }
        }
        TreeMap<String, AccreditationBean[]> accreditationSummary = new TreeMap<String, AccreditationBean[]>();
        AccreditationBean[] summary = new AccreditationBean[] { accredA, accredB };

        accreditationSummary.put("Accreditation", summary);
        searchCriteria.setTrainingSummary("Search", accreditationSummary);
    }

    if (!StringUtils.equalsIgnoreCase(strTrainingStatus, "Null")) {
        searchCriteria.setTrainingStatus(strTrainingStatus);
    }
    if (StringUtils.isNotBlank(strTrainingStatusDetail)
            && !StringUtils.equalsIgnoreCase(strTrainingStatusDetail, "Any")) {
        searchCriteria.setTrainingStatusDetail(strTrainingStatusDetail);
    }

    /* Check if specialty details were set */
    boolean specialty = false;
    SpecialtyBean specialtyCriteria = new SpecialtyBean();
    SpecialtyBean specialtyConstraints = new SpecialtyBean();

    if (strTrainingOrganisation != null) {
        if (strTrainingOrganisation.compareTo("Null") != 0) {
            specialtyCriteria.setTrainingOrganisation(strTrainingOrganisation);
            specialty = true;
        }
    }
    if (strTrainingProgram != null) {
        if (strTrainingProgram.compareTo("Any") != 0) {
            specialtyCriteria.setTrainingProgram(strTrainingProgram);
            specialty = true;
        }
    }

    if (StringUtils.isNotBlank(trainingProgramYearA)) {
        int trainingProgramYear = 0;
        try {
            trainingProgramYear = Integer.parseInt(trainingProgramYearA);
        } catch (NumberFormatException nfe) {
            dataLogger.debug("Error parsing training year A: " + nfe.getMessage());
        }
        if (StringUtils.equalsIgnoreCase(trainingProgramYearA, "+")) {
            trainingProgramYear = MAXIMUM_YEAR;
        }
        if (StringUtils.equalsIgnoreCase(trainingProgramYearA, "-")) {
            trainingProgramYear = MINIMUM_YEAR;
        }
        specialtyCriteria.setTrainingProgramYear(trainingProgramYear);
    }
    if (StringUtils.isNotBlank(trainingProgramYearB)) {
        int trainingProgramYear = 0;
        try {
            trainingProgramYear = Integer.parseInt(trainingProgramYearB);
        } catch (NumberFormatException nfe) {
            dataLogger.debug("Error parsing training program B: " + nfe.getMessage());
        }
        if (StringUtils.equalsIgnoreCase(trainingProgramYearB, "+")) {
            trainingProgramYear = MAXIMUM_YEAR;
        }
        if (StringUtils.equalsIgnoreCase(trainingProgramYearB, "-")) {
            trainingProgramYear = MINIMUM_YEAR;
        }
        specialtyConstraints.setTrainingProgramYear(trainingProgramYear);
    }

    if (strSpecialtyStatus != null) {
        if (strSpecialtyStatus.compareTo("Null") != 0) {
            specialtyCriteria.setStatus(strSpecialtyStatus);
            specialty = true;
        }
    }
    if (specialty) {
        ArrayList<SpecialtyBean> spCriteria = new ArrayList<SpecialtyBean>();
        ArrayList<SpecialtyBean> spConstraints = new ArrayList<SpecialtyBean>();
        spCriteria.add(specialtyCriteria);
        spConstraints.add(specialtyConstraints);
        searchCriteria.setSpecialtyList(spCriteria);
        searchConstraints.setSpecialtyList(spConstraints);
    }

    // Check if address details have been submitted
    boolean address = false;
    AddressBean addressCriteria = new AddressBean();
    AddressBean addressConstraints = new AddressBean();
    // Address defaults
    addressCriteria.setReturnedMail(false);
    addressConstraints.setReturnedMail(true);
    addressCriteria.setRequestNoMail(false);
    addressConstraints.setRequestNoMail(true);

    // Set the address class and type - but don't set the address flag yet
    if (StringUtils.isNotBlank(strAddressClass)) {
        if (StringUtils.equalsIgnoreCase(strAddressClass, "Preferred")) {
            // Set the primary flag to true
            addressCriteria.setPrimary(true);
            addressConstraints.setPrimary(true);
        } else {
            // Set the address class
            addressCriteria.setContactClass(strAddressClass);
        }
    }
    if (StringUtils.isNotBlank(strAddressType)) {
        // Set the address type
        addressCriteria.setContactType(strAddressType);
    }

    // Set the address city
    if (StringUtils.isNotBlank(strCity)) {
        addressCriteria.setAddressField(strCity);
        address = true;
    }
    // Set the address country
    if (StringUtils.isNotBlank(strCountry)) {
        addressCriteria.setCountry(strCountry);
        address = true;
    }
    // Set the returned mail
    if (StringUtils.equals(strAddressReturnedMail, "true")) {
        addressCriteria.setReturnedMail(true);
        addressConstraints.setReturnedMail(true);
        address = true;
    }
    if (StringUtils.equals(strAddressReturnedMail, "false")) {
        addressCriteria.setReturnedMail(false);
        addressConstraints.setReturnedMail(false);
        address = true;
    }
    // Set the request mail
    if (StringUtils.equals(strAddressRequestNoMail, "true")) {
        addressCriteria.setRequestNoMail(true);
        addressConstraints.setRequestNoMail(true);
        address = true;
    }
    if (StringUtils.equals(strAddressRequestNoMail, "false")) {
        addressCriteria.setRequestNoMail(false);
        addressConstraints.setRequestNoMail(false);
        address = true;
    }

    if (address) {
        Collection<AddressBean> addresses = new ArrayList<AddressBean>();
        Collection<AddressBean> addresses2 = new ArrayList<AddressBean>();
        addresses.add(addressCriteria);
        addresses2.add(addressConstraints);
        searchCriteria.setAddress(addresses);
        searchConstraints.setAddress(addresses2);
    }

    // Check if Email details have been submitted
    boolean email = false;
    EmailBean emailCriteria = new EmailBean();
    EmailBean emailConstraints = new EmailBean();

    // Email defaults
    emailCriteria.setReturnedMail(true);
    emailConstraints.setReturnedMail(false);
    emailCriteria.setRequestNoMail(true);
    emailConstraints.setRequestNoMail(false);
    emailCriteria.setEmailQuestions(true);
    emailConstraints.setEmailQuestions(false);

    // Set the email type - but don't set the address flag yet
    if (StringUtils.isNotBlank(strEmailType)) {
        if (StringUtils.equalsIgnoreCase(strEmailType, "Preferred")) {
            // Set the primary flag to true
            emailCriteria.setPrimary(true);
            emailConstraints.setPrimary(true);
        } else {
            // Set the email type
            emailCriteria.setContactType(strEmailType);
        }
    }

    if (StringUtils.equals(strEmailReturnedMail, "true")) {
        emailCriteria.setReturnedMail(true);
        emailConstraints.setReturnedMail(true);
        email = true;
    }
    if (StringUtils.equals(strEmailReturnedMail, "false")) {
        emailCriteria.setReturnedMail(false);
        emailConstraints.setReturnedMail(false);
        email = true;
    }
    if (StringUtils.equals(strEmailRequestNoMail, "true")) {
        emailCriteria.setRequestNoMail(true);
        emailConstraints.setRequestNoMail(true);
        email = true;
    }
    if (StringUtils.equals(strEmailRequestNoMail, "false")) {
        emailCriteria.setRequestNoMail(false);
        emailConstraints.setRequestNoMail(false);
        email = true;
    }
    if (StringUtils.equals(strEmailQuestions, "true")) {
        emailCriteria.setEmailQuestions(true);
        emailConstraints.setEmailQuestions(true);
        email = true;
    }
    if (StringUtils.equals(strEmailQuestions, "false")) {
        emailCriteria.setEmailQuestions(false);
        emailConstraints.setEmailQuestions(false);
        email = true;
    }

    if (email) {
        Collection<EmailBean> emails = new ArrayList<EmailBean>();
        Collection<EmailBean> emails2 = new ArrayList<EmailBean>();
        emails.add(emailCriteria);
        emails2.add(emailConstraints);
        searchCriteria.setEmail(emails);
        searchConstraints.setEmail(emails2);
    }

    if (StringUtils.isNotBlank(strClosingBalanceA) && !StringUtils.equals(strClosingBalanceA, "Null")) {

        // Something has been defined for this field
        double closingBalanceA = 0;
        double closingBalanceB = 0;

        try {
            closingBalanceA = Double.parseDouble(strClosingBalanceA);
        } catch (NumberFormatException nfe) {
            closingBalanceA = 0;
        }
        try {
            closingBalanceB = Double.parseDouble(strClosingBalanceB);
        } catch (NumberFormatException nfe) {
            closingBalanceB = 0;
        }

        if (StringUtils.equals(strClosingBalanceB, "-")) {
            closingBalanceB = -100000000;
        }
        if (StringUtils.equals(strClosingBalanceB, "+")) {
            closingBalanceB = 100000000;
        }

        FinancialSummaryBean financialSummaryCriteria = new FinancialSummaryBean();
        // This is a unique id to indicate the financial summary has been set
        financialSummaryCriteria.setId(1);
        financialSummaryCriteria.setClosingBalance(closingBalanceA);
        searchCriteria.setFinancialSummary(financialSummaryCriteria);

        if (closingBalanceB != 0) {
            FinancialSummaryBean financialSummaryConstraints = new FinancialSummaryBean();
            financialSummaryConstraints.setClosingBalance(closingBalanceB);
            searchConstraints.setFinancialSummary(financialSummaryConstraints);
        }
    }

    if (StringUtils.isNotBlank(strOrganisation)) {
        TreeMap<String, ItemBean> employers = new TreeMap<String, ItemBean>();
        ItemBean employer = new ItemBean();
        employer.setName(strOrganisation);
        employers.put(strOrganisation, employer);
        searchCriteria.setEmployers(employers);
    }

    WorkshopBean workshopCriteria = new WorkshopBean();
    WorkshopBean workshopConstraints = new WorkshopBean();
    boolean workshopSearch = false;

    if (strWorkshopType != null) {
        if (strWorkshopType.compareTo("") != 0) {
            if (strWorkshopType.compareTo("Null") != 0) {
                workshopCriteria.setType(strWorkshopType);
                workshopSearch = true;
            }
        }
    }
    if (strWorkshopAttendance != null) {
        if (strWorkshopAttendance.compareTo("") != 0) {
            workshopCriteria.setMemo(strWorkshopAttendance);
            workshopSearch = true;
        }
    }
    if (strWorkshopYear != null) {
        if (strWorkshopYear.compareTo("") != 0) {
            try {
                String startDate = "1/1/" + strWorkshopYear;
                String endDate = "31/12/" + strWorkshopYear;
                workshopCriteria.setWorkshopDate(DataFilter.parseDate(startDate, false));
                workshopConstraints.setWorkshopDate(DataFilter.parseDate(endDate, false));
                workshopSearch = true;
            } catch (Exception e) {
                dataLogger.debug("Error setting workshop details: " + e.getMessage());
            }
        }
    }
    if (workshopSearch) {
        ArrayList<WorkshopBean> workshops1 = new ArrayList<WorkshopBean>();
        ArrayList<WorkshopBean> workshops2 = new ArrayList<WorkshopBean>();
        workshops1.add(workshopCriteria);
        workshops2.add(workshopConstraints);
        searchCriteria.setWorkshops(workshops1);
        searchConstraints.setWorkshops(workshops2);
    }

    // Check if exam was set...
    boolean examSearch = false;
    ExamBean examCriteria = new ExamBean();
    ExamBean examConstraint = new ExamBean();

    if (strExamType != null) {
        if (strExamType.compareTo("") != 0 && strExamType.compareTo("Null") != 0) {
            examCriteria.setType(strExamType);
            examSearch = true;
        }
    }
    if (strExamStatus != null) {
        if (strExamStatus.compareTo("") != 0 && strExamStatus.compareTo("Null") != 0) {
            examCriteria.setStatus(strExamStatus);
            examSearch = true;
        }
    }
    if (strExamStatusLevel != null) {
        if (strExamStatusLevel.compareTo("") != 0 && strExamStatusLevel.compareTo("Any") != 0) {
            examCriteria.setStatusLevel(strExamStatusLevel);
            examSearch = true;
        }
    }
    if (strExamDateA != null) {
        if (strExamDateA.compareTo("") != 0) {
            examCriteria.setDateSat(DataFilter.parseDate(strExamDateA, false));
            examSearch = true;
        }
    }
    if (strExamDateB != null) {
        if (strExamDateB.compareTo("") != 0) {

            examConstraint.setDateSat(DataFilter.parseDate(strExamDateB, false));

            if (strExamDateB.compareTo("+") == 0) {
                /* All dates above Date A requested */
                examConstraint.setDateSat(getMaximumDate());
            }
            if (strExamDateB.compareTo("-") == 0) {
                /* Add dates below Date A requested */
                examConstraint.setDateSat(getMinimumDate());
            }
        }
    }
    if (examSearch) {
        Collection<ExamBean> exams1 = new ArrayList<ExamBean>();
        Collection<ExamBean> exams2 = new ArrayList<ExamBean>();
        exams1.add(examCriteria);
        exams2.add(examConstraint);
        searchCriteria.setExams(exams1);
        searchConstraints.setExams(exams2);
    }

    /* Check if qualification was set */
    boolean qualificationSearch = false;
    QualificationBean qualificationCriteria = new QualificationBean();
    QualificationBean qualificationConstraint = new QualificationBean();

    if (strQualificationType != null) {
        if (strQualificationType.compareTo("") != 0 && strQualificationType.compareTo("Null") != 0) {
            qualificationCriteria.setQualificationType(strQualificationType);
            qualificationSearch = true;
        }
    }
    if (strQualificationSubType != null) {
        if (strQualificationSubType.compareTo("") != 0 && strQualificationSubType.compareTo("Any") != 0) {
            qualificationCriteria.setQualificationSubType(strQualificationSubType);
            qualificationSearch = true;
        }
    }
    if (strQualificationInstitution != null) {
        if (strQualificationInstitution.compareTo("") != 0) {
            qualificationCriteria.setInstitution(strQualificationInstitution);
            qualificationSearch = true;
        }
    }
    if (strQualificationCountry != null) {
        if (strQualificationCountry.compareTo("") != 0) {
            qualificationCriteria.setCountry(strQualificationCountry);
            qualificationSearch = true;
        }
    }
    if (strGraduatedA != null) {
        if (strGraduatedA.compareTo("") != 0) {
            try {
                qualificationCriteria.setYear(Integer.parseInt(strGraduatedA));
                qualificationSearch = true;
            } catch (Exception e) {
                dataLogger.info("Error parsing graduated year A: " + e.getMessage());
            }
        }
    }
    if (strGraduatedB != null) {
        try {
            qualificationConstraint.setYear(Integer.parseInt(strGraduatedB));
        } catch (NumberFormatException nfe) {
            dataLogger.info("Error parsing graduated year B: " + nfe.getMessage());
        }
        if (strGraduatedB.compareTo("+") == 0) {
            /* All qualifications above graduated A requested */
            qualificationConstraint.setYear(MAXIMUM_YEAR);
        }
        if (strGraduatedB.compareTo("-") == 0) {
            /* Add qualifications below graduated A requested */
            qualificationConstraint.setYear(MINIMUM_YEAR);
        }
    }
    if (qualificationSearch) {
        Collection<QualificationBean> qualifications1 = new ArrayList<QualificationBean>();
        Collection<QualificationBean> qualifications2 = new ArrayList<QualificationBean>();
        qualifications1.add(qualificationCriteria);
        qualifications2.add(qualificationConstraint);
        searchCriteria.setQualifications(qualifications1);
        searchConstraints.setQualifications(qualifications2);
    }

    // Rotation parameters
    if (strRotationGUID != null) {
        int guid = 0;
        try {
            guid = Integer.parseInt(strRotationGUID);
        } catch (NumberFormatException nfe) {
            guid = 0;
        }
        if (guid > 0) {
            RotationBean rotation = new RotationBean();
            rotation.setGUID(guid);

            Collection<RotationBean> rotations = new ArrayList<RotationBean>();
            rotations.add(rotation);

            searchCriteria.setRotations(rotations);
        }
    }

    if (strCreatedA != null) {
        if (strCreatedA.compareTo("") != 0) {
            searchCriteria.setCreatedDate(DataFilter.parseDate(strCreatedA, false));
        }
    }
    if (strCreatedB != null) {
        if (strCreatedB.compareTo("") != 0) {

            searchConstraints.setCreatedDate(DataFilter.parseDate(strCreatedB, false));

            if (strCreatedB.compareTo("+") == 0) {
                /* All dates above Date A requested */
                searchConstraints.setCreatedDate(getMaximumDate());
            }
            if (strCreatedB.compareTo("-") == 0) {
                /* Add dates below Date A requested */
                searchConstraints.setCreatedDate(getMinimumDate());
            }
        }
    }
    if (strUpdatedA != null) {
        if (strUpdatedA.compareTo("") != 0) {
            searchCriteria.setModifiedDate(DataFilter.parseDate(strUpdatedA, false));
        }
    }
    if (strUpdatedB != null) {
        if (strUpdatedB.compareTo("") != 0) {

            searchConstraints.setModifiedDate(DataFilter.parseDate(strUpdatedB, false));

            if (strUpdatedB.compareTo("+") == 0) {
                /* All dates above Date A requested */
                searchConstraints.setModifiedDate(getMaximumDate());
            }
            if (strUpdatedB.compareTo("-") == 0) {
                /* Add dates below Date A requested */
                searchConstraints.setModifiedDate(getMinimumDate());
            }
        }
    }

    search.setSearchCriteria(searchCriteria);
    search.setSearchConstraints(searchConstraints);

    return search;
}

From source file:de.thorstenberger.examServer.webapp.action.PDFBulkExport.java

@Override
public ActionForward execute(final ActionMapping mapping, final ActionForm form,
        final HttpServletRequest request, final HttpServletResponse response) throws Exception {

    final ActionMessages errors = new ActionMessages();

    // locate the taskdef to use
    long taskId;//from   w  ww. j av a  2  s . c o  m
    try {
        taskId = Long.parseLong(request.getParameter("taskId"));
    } catch (final NumberFormatException e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("invalid.parameter"));
        saveErrors(request, errors);
        return mapping.findForward("error");
    }

    final TaskManager tm = (TaskManager) getBean("TaskManager");
    final TaskDef td = tm.getTaskDef(taskId);
    final UserManager userManager = (UserManager) getBean("userManager");

    if (request.getUserPrincipal() == null) {
        throw new RuntimeException("Not logged in.");
    }
    // we only know how to handle complextasks yet
    if (td.getType().equals(TaskContants.TYPE_COMPLEX)) {
        // initialize web crawler
        final PDFExporter pdfExporter = new PDFExporter(userManager, tm);

        // show an error message if tomcat isn't configured appropriately
        if (!pdfExporter.isAvailableWithoutCertificate()) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("invalid.serverconfig"));
            saveErrors(request, errors);
            return mapping.findForward("error");
        }
        // set response headers to declare pdf content type
        response.setContentType("application/zip");
        response.setHeader("Content-Disposition", "attachment; filename=" + getBulkFilename(td));
        // locate the taskdef
        TaskDef_Complex ctd;
        try {
            ctd = (TaskDef_Complex) td;
        } catch (final ClassCastException e) {
            throw new RuntimeException("invalid type: \"" + td.getType() + "\", " + e.getMessage());
        }
        // write headers, start streaming to the client
        response.flushBuffer();

        // get all tasklets for the given taskdef
        final List<Tasklet> tasklets = tm.getTaskletContainer().getTasklets(taskId);
        log.info(String.format("Exporting %d pdfs for taskdef \"%s\"", tasklets.size(), ctd.getTitle()));

        renderAllPdfs(tasklets, response.getOutputStream(), pdfExporter);
        return null;
    } else {
        throw new RuntimeException("unsupported type: \"" + td.getType() + "\"");
    }

}

From source file:de.interactive_instruments.ShapeChange.Target.SQL.SqlDdl.java

/**
 * Determines the applicable 'size' for the given property. If the tagged
 * value {@value #PARAM_SIZE} is set for the property, its value is
 * returned. Otherwise the default value (given via the configuration
 * parameter {@value #PARAM_SIZE} or as defined by this class [
 * {@value #DEFAULT_SIZE}]) applies.//from w  w  w  .  ja v a2  s . c  om
 *
 * @param pi
 * @return
 */
private int getSizeForProperty(PropertyInfo pi) {

    String tvSize = pi.taggedValuesAll().getFirstValue(PARAM_SIZE);

    int size = defaultSize;

    if (tvSize != null) {
        try {
            size = Integer.parseInt(tvSize);
        } catch (NumberFormatException e) {
            MessageContext mc = result.addWarning(this, 5, PARAM_SIZE, e.getMessage(), "" + defaultSize);
            mc.addDetail(this, 0);
            mc.addDetail(this, 100, pi.name(), pi.inClass().name());
            size = defaultSize;
        }
    }

    return size;
}

From source file:net.naijatek.myalumni.util.taglib.BuildImageTag.java

/**
 * Process the end of this tag./* w  ww  .  jav  a2 s. c o m*/
 * 
 * @throws JspException
 *             if a JSP exception has occurred
 * @return int
 */
@Override
public final int doEndTag() throws JspException {

    request = (HttpServletRequest) pageContext.getRequest();

    String uploadDir = BaseConstants.UPLOAD_DIR_NAME;
    String logoUploadDir = BaseConstants.LOGO_UPLOAD_DIR_NAME;
    String adsUploadDir = BaseConstants.ADS_UPLOAD_DIR_NAME;
    String avatarUploadDir = BaseConstants.AVATAR_UPLOAD_DIR_NAME;
    String seperator = "/";
    String width_ad = app.getValue("image.width");

    String width_avatar = app.getValue("avatar.image.width");
    String height_avatar = app.getValue("avatar.image.height");
    String name_of_avatar = app.getValue("avatar.image.name");

    String rootContext = request.getContextPath();

    StringBuffer sb = new StringBuffer();
    if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_ADVERTISEMENT)) {
        if (imageUrl.length() > 0) {
            sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + adsUploadDir
                    + seperator + imageUrl.trim() + "\" border=\"0\" width=\"" + width_ad + "\">");
        } else {
            sb.append(
                    "<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "" + name_of_avatar
                            + "" + "\" border=\"0\" width=\"150\" height=\"150\" align=\"ABSMIDDLE\">");
        }
        // logger.debug("Advertisement url = " + sb.toString());
    } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_EDITABLE_AVATAR)) {
        if (imageUrl.length() > 0) {
            sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + avatarUploadDir
                    + seperator + imageUrl.trim() + "\" border=\"0\" width=\"" + width_avatar + "\" "
                    + "height=\"" + height_avatar + "\" align=\"absmiddle\">");
        } else {
            sb.append(
                    "<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "" + name_of_avatar
                            + "" + "\" border=\"0\" width=\"150\" height=\"150\" align=\"absmiddle\">");

        }
    } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_LOGO)) {
        if (imageUrl.trim() != null && imageUrl.trim().length() > 0) {
            File f = new File(sysProp.getValue("LOGO.FILEPATH") + seperator + imageUrl.trim());
            if (!f.isDirectory() && f.exists()) {
                sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + logoUploadDir
                        + seperator + imageUrl.trim() + "\" border=\"0\" align=\"absmiddle\" altKey=\""
                        + app.getValue("application.name") + "\"  titleKey=\""
                        + app.getValue("application.name") + "\">");
            } else {
                sb.append(app.getValue("error.logonotfound"));
            }
        } else {
            sb.append("<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "logo" + seperator
                    + "myalumni_03.png\" border=\"0\" align=\"absmiddle\" altKey=\""
                    + app.getValue("application.name") + "\"  titleKey=\"" + app.getValue("application.name")
                    + "\">");
        }
    } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_AVATAR)) {
        if (imageUrl.length() > 0) {
            sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + avatarUploadDir
                    + seperator + imageUrl.trim() + "\" border=\"0\" width=\"" + width_avatar + "\" "
                    + "height=\"" + height_avatar + "\" align=\"absmiddle\">");
        } else {
            sb.append(
                    "<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "" + name_of_avatar
                            + "" + "\" border=\"0\" width=\"150\" height=\"150\" align=\"absmiddle\">");

        }
        // logger.debug("Avatar url = " + sb.toString());
    } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_IMAGE)) { // Display
        // a
        // regular
        // image
        // int quotaRatio = 0 ;
        int quota = 0;

        try {
            quota = Integer.parseInt(imageUrl);
        } catch (NumberFormatException e) {
            quota = 0;
        }

        double imageWidth = ((quota * 100) / SystemConfigConstants.MAIL_QUOTA) / .3;
        double usedQuotaPercent = quota / (SystemConfigConstants.MAIL_QUOTA / 100);

        if (imageUrl.length() > 0) {
            if (usedQuotaPercent < 70) {
                sb.append("<img align=\"left\" width=\"" + imageWidth + "\" height=\"15\" src=\""
                        + rootContext.trim() + seperator + "images" + seperator + "icon" + seperator
                        + "percent_low.gif" + "\" vspace=\"0\" hspace=\"0\" alt=\"Low Mail Percentage\"/>");
            } else if (usedQuotaPercent <= 85) {
                sb.append("<img align=\"left\" width=\"" + imageWidth + "\" height=\"15\" src=\""
                        + rootContext.trim() + seperator + "images" + seperator + "icon" + seperator
                        + "percent_med.gif" + "\" vspace=\"0\" hspace=\"0\" alt=\"Medium Mail Percentage\"/>");
            } else {
                sb.append("<img align=\"left\" width=\"" + imageWidth + "\" height=\"15\" src=\""
                        + rootContext.trim() + seperator + "images" + seperator + "icon" + seperator
                        + "percent_high.gif" + "\" vspace=\"0\" hspace=\"0\" alt=\"High Mail Percentage\"/>");
            }
        }
    }
    try {
        pageContext.getOut().print(sb.toString());
    } catch (Exception e) {
        logger.debug(e.getMessage());
        throw new JspException("IO Problem in BuildImageTag " + e.getMessage());
    }

    return EVAL_PAGE;
}

From source file:jp.terasoluna.fw.web.struts.taglib.PageLinksTag.java

/**
 * ?IuWFNgintp?B/*from ww  w . j a v a  2  s.  c  o m*/
 * 
 * @param obj intIuWFNg 
 * @return l
 * @throws JspException JSPO
 */
protected int getInt(Object obj) throws JspException {
    int retInt = 0;
    String value = ObjectUtils.toString(obj);
    if (!"".equals(value)) {
        try {
            retInt = Integer.parseInt(value);
        } catch (NumberFormatException e) {
            log.error(e.getMessage());
            throw new JspException(e);
        }
    }
    return retInt;
}

From source file:com.palantir.stash.disapprove.servlet.DisapprovalServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

    final String user = authenticateUser(req, res);
    if (user == null) {
        // not logged in, redirect
        res.sendRedirect(lup.getLoginUri(getUri(req)).toASCIIString());
        return;/*from   w w  w .j a  v  a  2  s .c o m*/
    }

    final String REQ_PARAMS = "repoId(int), prId(long), disapproved(true|false)";
    final Integer repoId;
    final Long prId;
    try {
        repoId = Integer.valueOf(req.getParameter("repoId"));
        prId = Long.valueOf(req.getParameter("prId"));
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException("The required paramaters are: " + REQ_PARAMS, e);
    }
    final PullRequest pr = pullRequestService.getById(repoId, prId);
    final Repository repo = pr.getToRef().getRepository();

    PullRequestDisapproval prd;
    DisapprovalConfiguration dc;
    try {
        prd = pm.getPullRequestDisapproval(pr);
        dc = pm.getDisapprovalConfiguration(repo);
    } catch (SQLException e) {
        throw new ServletException(e);
    }

    boolean oldDisapproval = prd.isDisapproved();
    boolean disapproval;

    String disapproved = req.getParameter("disapproved");
    if (disapproved != null && disapproved.equalsIgnoreCase("true")) {
        disapproval = true;
    } else if (disapproved != null && disapproved.equalsIgnoreCase("false")) {
        disapproval = false;
    } else {
        throw new IllegalArgumentException("The required parameters are: " + REQ_PARAMS);
    }
    Writer w = res.getWriter();
    res.setContentType("application/json;charset=UTF-8");
    try {
        processDisapprovalChange(repo, user, prd, oldDisapproval, disapproval);
        //res.setContentType("text/html;charset=UTF-8");
        w.append(new JSONObject(ImmutableMap.of("disapproval", prd.isDisapproved(), "disapprovedBy",
                prd.getDisapprovedBy(), "enabledForRepo", dc.isEnabled())).toString());
    } catch (IllegalStateException e) {
        w.append(new JSONObject(ImmutableMap.of("error", e.getMessage())).toString());
        res.setStatus(401);
    } finally {
        w.close();
    }
}

From source file:com.appdynamics.monitors.pingdom.communicator.PingdomCommunicator.java

@SuppressWarnings("rawtypes")
private void getCredits(Map<String, Integer> metrics) {

    try {//from   w  w  w  .j a v  a  2s  .  co m
        HttpClient httpclient = new DefaultHttpClient();

        UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
        HttpGet httpget = new HttpGet(baseAddress + "/api/2.0/credits");
        httpget.addHeader(BasicScheme.authenticate(creds, "US-ASCII", false));
        httpget.addHeader("App-Key", appkey);

        HttpResponse response;
        response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

        // reading in the JSON response
        String result = "";
        if (entity != null) {
            InputStream instream = entity.getContent();
            int b;
            try {
                while ((b = instream.read()) != -1) {
                    result += Character.toString((char) b);
                }
            } finally {
                instream.close();
            }
        }

        // parsing the JSON response
        try {

            JSONParser parser = new JSONParser();

            ContainerFactory containerFactory = new ContainerFactory() {
                public List creatArrayContainer() {
                    return new LinkedList();
                }

                public Map createObjectContainer() {
                    return new LinkedHashMap();
                }
            };

            // retrieving the metrics and populating HashMap
            JSONObject obj = (JSONObject) parser.parse(result);
            if (obj.get("credits") == null) {
                logger.error("Error retrieving data. " + obj);
                return;
            }
            Map json = (Map) parser.parse(obj.get("credits").toString(), containerFactory);

            if (json.containsKey("autofillsms")) {
                if (json.get("autofillsms").toString().equals("false")) {
                    metrics.put("Credits|autofillsms", 0);
                } else if (json.get("autofillsms").toString().equals("true")) {
                    metrics.put("Credits|autofillsms", 1);
                } else {
                    logger.error("can't determine whether Credits|autofillsms is true or false!");
                }
            }

            if (json.containsKey("availablechecks")) {
                try {
                    metrics.put("Credits|availablechecks",
                            Integer.parseInt(json.get("availablechecks").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|availablechecks!");
                }
            }

            if (json.containsKey("availablesms")) {
                try {
                    metrics.put("Credits|availablesms", Integer.parseInt(json.get("availablesms").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|availablesms!");
                }
            }

            if (json.containsKey("availablesmstests")) {
                try {
                    metrics.put("Credits|availablesmstests",
                            Integer.parseInt(json.get("availablesmstests").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|availablesmstests!");
                }
            }

            if (json.containsKey("checklimit")) {
                try {
                    metrics.put("Credits|checklimit", Integer.parseInt(json.get("checklimit").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|checklimit!");
                }
            }

        } catch (ParseException e) {
            logger.error("JSON Parsing error: " + e.getMessage());
        } catch (Throwable e) {
            logger.error(e.getMessage());
        }

    } catch (IOException e1) {
        logger.error(e1.getMessage());
    } catch (Throwable t) {
        logger.error(t.getMessage());
    }

}