Example usage for java.text ParseException getMessage

List of usage examples for java.text ParseException getMessage

Introduction

In this page you can find the example usage for java.text ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJInt16Editor.java

public Short getInt16Value() {
    final String S_ProcName = "getInt16Value";
    Short retval;//from ww  w.  j a  v  a  2  s . c o m
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = (Short) s;
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Short(i.shortValue());
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Short(l.shortValue());
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Short(n.shortValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

From source file:com.neusoft.mid.clwapi.service.photo.PhotoServiceImpl.java

/**
 * ??//from  w w w .ja va  2  s.  c  o  m
 * 
 * @param token
 *            token
 * @param body
 *            ?
 * @return
 */
@Override
public Object getSignInfo(String token, String body) {
    logger.info("???");

    PhotoSignRequ iPhotoSignRequ = JacksonUtils.fromJsonRuntimeException(body, PhotoSignRequ.class);
    logger.info("ID" + iPhotoSignRequ.getImgId());
    logger.info("" + iPhotoSignRequ.getUpTime());
    logger.info("??");
    // ?
    if (StringUtils.isEmpty(iPhotoSignRequ.getImgId()) || StringUtils.isEmpty(iPhotoSignRequ.getUpTime())) {
        logger.error("??");
        throw new ApplicationException(ErrorConstant.ERROR10001, Response.Status.BAD_REQUEST);
    }

    // 0?
    if (iPhotoSignRequ.getUpTime().equals(HttpConstant.TIME_ZERO)) {
        iPhotoSignRequ.setUpTime(null);
    } else {
        // ?
        try {
            BeanUtil.checkTimeForm(iPhotoSignRequ.getUpTime(), HttpConstant.TIME_FORMAT);
        } catch (ParseException e) {
            logger.error("?" + e.getMessage());
            throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
        }
    }

    logger.info("??");
    // ??
    PhotoSignInfo iPhotoSignInfo = iPhotoMapper.getPhotoSign(iPhotoSignRequ);

    // ?
    if (iPhotoSignInfo == null || iPhotoSignInfo.getInfo() == null) {
        logger.info("?");
        return Response.noContent().build();
    }

    logger.info("????");
    logger.debug(iPhotoSignInfo.toString());

    logger.info("????");
    return JacksonUtils.toJsonRuntimeException(iPhotoSignInfo);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJInt32Editor.java

public Integer getInt32Value() {
    final String S_ProcName = "getInt32Value";
    Integer retval;/*w ww . j a  va2  s. c  o  m*/
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer((int) v);
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = i;
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer(l.intValue());
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer(n.intValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJInt64Editor.java

public Long getInt64Value() {
    final String S_ProcName = "getInt64Value";
    Long retval;//w  ww  .j a  va  2 s  .c  o m
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long((long) v);
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long((long) v);
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = l;
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long(n.longValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

From source file:org.kuali.kfs.module.endow.web.struts.TransactionStatementAction.java

/**
 * Generates Transaction Statement in the PDF form
 * //  w ww  .ja  va2s. c  om
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward print(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    TransactionStatementReportService transactionStatementReportService = SpringContext
            .getBean(TransactionStatementReportService.class);

    // get all the value strings from the form
    TransactionStatementForm transactionStatementForm = (TransactionStatementForm) form;
    String kemids = transactionStatementForm.getKemid();
    String benefittingOrganziationCampuses = transactionStatementForm.getBenefittingOrganziationCampus();
    String benefittingOrganziationCharts = transactionStatementForm.getBenefittingOrganziationChart();
    String benefittingOrganziations = transactionStatementForm.getBenefittingOrganziation();
    String typeCodes = transactionStatementForm.getTypeCode();
    String purposeCodes = transactionStatementForm.getPurposeCode();
    String combineGroupCodes = transactionStatementForm.getCombineGroupCode();
    String beginningDate = transactionStatementForm.getBeginningDate();
    String endingDate = transactionStatementForm.getEndingDate();
    String endowmentOption = transactionStatementForm.getEndowmentOption();
    String listKemidsInHeader = transactionStatementForm.getListKemidsInHeader();
    String closedIndicator = transactionStatementForm.getClosedIndicator();
    String message = transactionStatementForm.getMessage();

    List<TransactionStatementReportDataHolder> transactionStatementReportDataHolders = null;

    // check to see if the ending date is greater than the beginning date
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
    try {
        java.util.Date beginDate = df.parse(beginningDate);
        java.util.Date endDate = df.parse(endingDate);

        if (beginDate.compareTo(endDate) >= 0) {
            transactionStatementForm.setMessage(ERROR_REPORT_ENDING_DATE_NOT_GREATER_THAN_BEGINNING_DATE);
            return mapping.findForward(KFSConstants.MAPPING_BASIC);
        }
    } catch (ParseException e) {
        transactionStatementForm.setMessage(e.getMessage());
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }

    /*
     * Creates the report data based on the selected criteria.
     * The criteria are selected as follows.
     * 1. Kemid and the other criteria cannot be selected at the same time.
     * 2. If none of them are selected, all kemids will be selected.
     * 3. The other criteria other than kemid are "OR" combined.
     * 4. All the criteria in the text input can be multiple by the use of wild card or the separator ('&' for kemid, ',' for the others) 
     * 5. Beginning Date and Ending Date are required.
     */

    if (StringUtils.isNotBlank(beginningDate) && StringUtils.isNotBlank(endingDate)) {
        if (StringUtils.isNotBlank(kemids)) {

            if ((StringUtils.isNotBlank(benefittingOrganziationCampuses)
                    || StringUtils.isNotBlank(benefittingOrganziationCharts)
                    || StringUtils.isNotBlank(benefittingOrganziations) || StringUtils.isNotBlank(typeCodes)
                    || StringUtils.isNotBlank(purposeCodes) || StringUtils.isNotBlank(combineGroupCodes))) {

                // kemid and the other criteria cannot be selected at the same time 
                transactionStatementForm.setMessage(ERROR_REPORT_KEMID_WITH_OTHER_CRITERIA);
                return mapping.findForward(KFSConstants.MAPPING_BASIC);

            } else {
                // by kemid only
                List<String> kemidList = parseValueString(kemids, KEMID_SEPERATOR);
                transactionStatementReportDataHolders = transactionStatementReportService
                        .getTransactionStatementReportsByKemidByIds(kemidList, beginningDate, endingDate,
                                endowmentOption, closedIndicator);
            }
        } else {
            if ((StringUtils.isBlank(benefittingOrganziationCampuses)
                    && StringUtils.isBlank(benefittingOrganziationCharts)
                    && StringUtils.isBlank(benefittingOrganziations) && StringUtils.isBlank(typeCodes)
                    && StringUtils.isBlank(purposeCodes) && StringUtils.isBlank(combineGroupCodes))) {

                // for all kemids
                transactionStatementReportDataHolders = transactionStatementReportService
                        .getTransactionStatementReportForAllKemids(beginningDate, endingDate, endowmentOption,
                                closedIndicator);

            } else {
                // by other criteria
                transactionStatementReportDataHolders = transactionStatementReportService
                        .getTransactionStatementReportsByOtherCriteria(
                                parseValueString(benefittingOrganziationCampuses, OTHER_CRITERIA_SEPERATOR),
                                parseValueString(benefittingOrganziationCharts, OTHER_CRITERIA_SEPERATOR),
                                parseValueString(benefittingOrganziations, OTHER_CRITERIA_SEPERATOR),
                                parseValueString(typeCodes, OTHER_CRITERIA_SEPERATOR),
                                parseValueString(purposeCodes, OTHER_CRITERIA_SEPERATOR),
                                parseValueString(combineGroupCodes, OTHER_CRITERIA_SEPERATOR), beginningDate,
                                endingDate, endowmentOption, closedIndicator);
            }
        }
    } else {
        transactionStatementForm.setMessage(ERROR_BOTH_BEGINNING_AND_ENDING_DATE_REQUIRED);
        return mapping.findForward(KFSConstants.MAPPING_BASIC);

    }

    // See to see if you have something to print        
    if (transactionStatementReportDataHolders != null && !transactionStatementReportDataHolders.isEmpty()) {
        // prepare the header sheet data
        EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder = transactionStatementReportService
                .createReportHeaderSheetData(getKemidsSelected(transactionStatementReportDataHolders),
                        parseValueString(benefittingOrganziationCampuses, OTHER_CRITERIA_SEPERATOR),
                        parseValueString(benefittingOrganziationCharts, OTHER_CRITERIA_SEPERATOR),
                        parseValueString(benefittingOrganziations, OTHER_CRITERIA_SEPERATOR),
                        parseValueString(typeCodes, OTHER_CRITERIA_SEPERATOR),
                        parseValueString(purposeCodes, OTHER_CRITERIA_SEPERATOR),
                        parseValueString(combineGroupCodes, OTHER_CRITERIA_SEPERATOR), REPORT_NAME,
                        endowmentOption, null);

        // generate the report in PDF 
        ByteArrayOutputStream pdfStream = new TransactionStatementReportPrint().printTransactionStatementReport(
                reportRequestHeaderDataHolder, transactionStatementReportDataHolders, listKemidsInHeader);
        if (pdfStream != null) {
            transactionStatementForm.setMessage("Reports Generated");
            WebUtils.saveMimeOutputStreamAsFile(response, "application/pdf", pdfStream, REPORT_FILE_NAME);
            return null;
        }
    }

    // No report was generated
    if (StringUtils.isBlank(kemids)) {
        transactionStatementForm.setMessage("Report was not generated.");
    } else {
        transactionStatementForm.setMessage("Report was not generated for " + kemids + ".");
    }

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:net.solarnetwork.node.weather.nz.metservice.MetserviceSupport.java

/**
 * Parse a Date from an attribute value.
 * /* w  w  w.  ja  v  a  2  s .c  om*/
 * <p>
 * If the date cannot be parsed, <em>null</em> will be returned.
 * </p>
 * 
 * @param key
 *        the attribute key to obtain from the {@code data} Map
 * @param data
 *        the attributes
 * @param dateFormat
 *        the date format to use to parse the date string
 * @return the parsed {@link Date} instance, or <em>null</em> if an error
 *         occurs or the specified attribute {@code key} is not available
 */
protected Date parseDateAttribute(String key, JsonNode data, SimpleDateFormat dateFormat) {
    Date result = null;
    if (data != null) {
        JsonNode node = data.get(key);
        if (node != null) {
            try {
                result = dateFormat.parse(node.asText());
            } catch (ParseException e) {
                log.debug("Error parsing date attribute [{}] value [{}] using pattern {}: {}",
                        new Object[] { key, data.get(key), dateFormat.toPattern(), e.getMessage() });
            }
        }
    }
    return result;
}

From source file:org.cgiar.ccafs.ap.action.projects.ProjectHighlightAction.java

@Override
public String save() {

    if (this.hasProjectPermission("update", project.getId())) {
        DateFormat dateformatter = new SimpleDateFormat(APConstants.DATE_FORMAT);
        // highlight.setStartDate(dateformatter.parse(dateformatter.format(highlight.getStartDate())));

        try {// w  w w.j ava  2s .c om
            highlight.setStartDate(dateformatter.parse(highlight.getStartDateText()));
            highlight.setEndDate(dateformatter.parse(highlight.getEndDateText()));
        } catch (ParseException e) {
            LOG.error(e.getMessage());
        }
        List<ProjectHighligthsTypes> actualTypes = new ArrayList<>();
        for (String type : highlight.getTypesids()) {
            ProjectHighligthsTypes typeHigh = new ProjectHighligthsTypes();
            typeHigh.setIdType(Integer.parseInt(type));
            typeHigh.setProjectHighligths(highlight);
            actualTypes.add(typeHigh);

        }
        List<ProjectHighligthsCountry> actualcountries = new ArrayList<>();
        for (Integer countries : highlight.getCountriesIds()) {
            ProjectHighligthsCountry countryHigh = new ProjectHighligthsCountry();
            countryHigh.setIdCountry(countries);
            countryHigh.setProjectHighligths(highlight);
            actualcountries.add(countryHigh);
        }

        if (file != null) {
            FileManager.deleteFile(this.getHightlightImagePath() + highlight.getPhoto());
            FileManager.copyFile(file, this.getHightlightImagePath() + fileFileName);
            highlight.setPhoto(fileFileName);
        }
        if (highlight.getPhoto().equals("-1")) {
            highlight.setPhoto(null);
        }

        highlight.setProjectId(new Long(project.getId() + ""));
        highlight.setProjectHighligthsTypeses(new HashSet<>(actualTypes));
        highlight.setProjectHighligthsCountries(new HashSet<>(actualcountries));
        highLightManager.saveHighLight(project.getId(), highlight, this.getCurrentUser(),
                this.getJustification());
        // Get the validation messages and append them to the save message
        Collection<String> messages = this.getActionMessages();
        if (!messages.isEmpty()) {
            String validationMessage = messages.iterator().next();
            this.setActionMessages(null);
            this.addActionWarning(this.getText("saving.saved") + validationMessage);
        } else {
            this.addActionMessage(this.getText("saving.saved"));
        }
        return SUCCESS;
    }
    return NOT_AUTHORIZED;
}

From source file:ch.cyberduck.core.dropbox.DropboxPath.java

@Override
public void readTimestamp() {
    try {/*w w  w  .ja  v a2s .co  m*/
        this.getSession().check();
        this.getSession().message(MessageFormat
                .format(Locale.localizedString("Getting timestamp of {0}", "Status"), this.getName()));

        ListEntryResponse response = this.readMetadata();
        try {
            this.attributes().setModificationDate(SIMPLE_DATE_FORMAT.parse(response.getModified()).getTime());
        } catch (ParseException e) {
            log.warn("Failed parsing modification date:" + e.getMessage());
        }
    } catch (IOException e) {
        this.error("Cannot read file attributes", e);
    }
}

From source file:com.krawler.spring.crm.common.globalSearchDAOImpl.java

public KwlReturnObject searchIndex(SearchBean bean, String querytxt, String numhits, String perpage,
        String startIn, String companyid, String userid, DateFormat dateFmt)
        throws ServiceException, IOException, JSONException {
    List ll1 = new ArrayList();
    Pattern p = Pattern.compile("^(?i)tag:[[\\s]*([\\w\\s]+[(/|\\{1})]?)*[\\s]*[\\w]+[\\s]*]*$");
    /*/*from   www  .j  av a2s. c om*/
     * "^([\'" + '"' + "]?)\\s*([\\w]+[(/|\\{1})]?)*[\\w]\\1$";
     */
    Matcher m = p.matcher(querytxt);
    boolean b = m.matches();
    JSONArray jarr = new JSONArray();
    JSONObject jobj = new JSONObject();
    if (!b) {
        String query = querytxt;
        String qfield = "PlainText";
        // TODO:numhits and hits per page to be used when paging tolbar is
        // attached to search grid
        int start = 0;
        int numofHitsPerPage = 10;
        int numofhits = 10;
        String resString = "{data:[";
        try {
            if (numhits != null) {
                numofhits = Integer.parseInt(numhits);
            }
            if (perpage != null) {
                numofHitsPerPage = Integer.parseInt(perpage);
            }
            if (startIn != null) {
                start = Integer.parseInt(startIn);
            }
            Hits hitresult = null;
            ArrayList filter_params = new ArrayList();
            String Hql = "select c.docid from com.krawler.common.admin.Docs c  where c.company.companyID=? and c.deleteflag=0";
            filter_params.add(companyid);
            List ll = executeQuery(Hql, filter_params.toArray());
            Iterator ite = ll.iterator();
            int dl = ll.size();
            if (query.length() > 2) {
                query += "*";
            }
            query = qfield + ":" + query;
            boolean flag = true;
            boolean found = false;
            Object row;
            while (ite.hasNext()) {
                row = (Object) ite.next();
                found = true;
                if (flag) {
                    query += " AND (";

                } else {
                    query += " OR ";
                }
                query += "DocumentId:" + row;
                flag = false;
            }
            query += ")";
            if (found) {
                hitresult = bean.skynetsearch(query, qfield);

                Iterator itr = hitresult.iterator();

                while (itr.hasNext()) {

                    Hit hit1 = (Hit) itr.next();
                    org.apache.lucene.document.Document doc = hit1.getDocument();
                    Enumeration docfields = doc.fields();
                    Summarizer summary = new Summarizer();
                    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                            "EEE MMM d HH:mm:ss z yyyy");
                    java.text.SimpleDateFormat sdf1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0");
                    java.util.Date dt = sdf.parse(doc.get("DateModified"));
                    JSONObject tmpObj = new JSONObject();
                    tmpObj.put("DocumentId", doc.get("DocumentId"));
                    tmpObj.put("FileName", doc.get("FileName"));
                    if (!StringUtil.isNullOrEmpty(doc.get("DateModified"))) {
                        tmpObj.put("DateModified", dateFmt.format(dt));
                    } else {
                        tmpObj.put("DateModified", "");
                    }
                    tmpObj.put("Author", doc.get("Author"));
                    String fileimage = com.krawler.esp.handlers.FileHandler.getFileImage(doc.get("FileName"),
                            1);
                    tmpObj.put("fileimage", fileimage);
                    tmpObj.put("Size", com.krawler.esp.handlers.FileHandler.getSizeKb(doc.get("Size")));
                    tmpObj.put("Type", doc.get("Type"));
                    tmpObj.put("Summary", URLEncoder
                            .encode(summary.getSummary(doc.get("PlainText"), querytxt).toString(), "UTF8")
                            .replace("+", "%20"));
                    jarr.put(tmpObj);
                }
            }
            jobj.put("data", jarr);
            resString += "]}";
        } catch (java.text.ParseException e) {
            logger.warn(e.getMessage(), e);
            throw ServiceException.FAILURE("SearchHandler.searchIndex", e);
        }
    } else {
        String resString = "{data:[";
        querytxt = querytxt.replaceFirst("(?i)tag:", "");
        querytxt = querytxt.trim();
        if (querytxt.contains(" ")) {
            querytxt = querytxt.replaceAll("\\s+", ",");
        }
        //   resString += docTagSearch(conn, querytxt, userid);

        if (resString.charAt(resString.length() - 1) != '[') {
            resString = resString.substring(0, (resString.length() - 1));
        }
        resString += "]}";
    }
    ll1.add(jobj);
    return new KwlReturnObject(true, KWLErrorMsgs.S01, "", ll1, 1);
}

From source file:org.apache.directory.fortress.web.panel.AuditBindListPanel.java

private void loadTree(List<Bind> binds) {
    for (Bind bind : binds) {
        Date start = null;//from   w  ww  . j  a v a2s .  c om
        try {
            start = TUtil.decodeGeneralizedTime(bind.getReqStart());
        } catch (ParseException pe) {
            LOG.warn("ParseException=" + pe.getMessage());
        }
        if (start != null) {
            SimpleDateFormat formatter = new SimpleDateFormat(GlobalIds.AUDIT_TIMESTAMP_FORMAT);
            String formattedDate = formatter.format(start);
            bind.setReqStart(formattedDate);
        }
        if (bind.getReqResult().equals(GlobalIds.BIND_SUCCESS_CODE)) {
            bind.setReqResult(GlobalIds.SUCCESS);
        } else {
            bind.setReqResult(GlobalIds.FAILURE);
        }
        bind.setReqDN(AuditUtils.getAuthZId(bind.getReqDN()));
        rootNode.add(new DefaultMutableTreeNode(bind));
    }
}