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:org.apache.directory.fortress.core.AuditMgrConsole.java

void printfailedAuthNReport(List<AuthZ> list) {
    ReaderUtil.clearScreen();/*  ww  w .j a  v a 2s  .  c  o m*/
    if (list != null && list.size() > 0) {
        int ctr = 0;
        for (AuthZ authZ : list) {
            /*
            public class AuthZ
            {
            private String createTimestamp;
            private String creatorsName;
            private String entryCSN;
            private String entryDN;
            private String entryUUID;
            private String hasSubordinates;
            private String modifiersName;
            private String modifyTimestamp;
            private String objectClass;
            private String reqAttr;
            private String reqAttrsOnly;
            private String reqAuthzID;
            private String reqControls;
            private String reqDN;
            private String reqDerefAliases;
            private String reqEnd;
            private String reqEntries;
            private String reqFilter;
            private String reqResult;
            private String reqScope;
            private String reqSession;
            private String reqSizeLimit;
            private String reqStart;
            private String reqTimeLimit;
            private String reqType;
            private String structuralObjectClass;
            private String subschemaSubentry;
            */
            //System.out.println("**********************************");
            System.out.println("FAILED AUTHENTICATIONS AUDIT RECORD " + ctr++);
            System.out.println("***************************************");
            Date aDate = null;
            try {
                aDate = TUtil.decodeGeneralizedTime(authZ.getReqEnd());
            } catch (ParseException pe) {
                System.out.println("    Access Time    " + "ParseException=" + pe.getMessage());
            }
            if (aDate != null) {
                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                String formattedDate = formatter.format(aDate);
                System.out.println("    Access Time     " + formattedDate);
            }
            System.out.println("    userId          " + AuditUtil.getAuthZId(authZ.getReqDN()));
            System.out.println("    Success?        " + authZ.getReqEntries().equals("1"));
            System.out.println("    reqDN           " + authZ.getReqDN());
            System.out.println();
            System.out.println();
        }
    } else {
        System.out.println("AuthZ list empty");
    }
}

From source file:com.bt.aloha.dialog.DialogSipBeanBase.java

public void sendReinviteOkResponse(final String dialogId, final MediaDescription mediaDescription) {
    LOG.debug(String.format("Sending reinvite response to dialog: %s", dialogId));
    if (mediaDescription == null)
        throw new IllegalArgumentException(
                String.format("Could not send reinvite response for dialog %s: no SDP", dialogId));

    ConcurrentUpdateBlock concurrentUpdateBlock = new ConcurrentUpdateBlock() {
        public void execute() {
            DialogInfo dialogInfo = getDialogCollection().get(dialogId);

            // TODO: a test for this
            if (dialogInfo.getReinviteInProgess().equals(ReinviteInProgress.None)) {
                LOG.warn(String.format(
                        "NOT sending reinivite OK response for dialog %s - no reinvite in progress", dialogId));
                return;
            }/*from w w  w. j  a v  a  2s .co  m*/

            dialogInfo.setReinviteInProgess(ReinviteInProgress.None);
            ServerTransaction serverTransaction = dialogInfo.getInviteServerTransaction();
            dialogInfo.setInviteServerTransaction(null);
            SessionDescriptionHelper.setMediaDescription(dialogInfo.getSessionDescription(), mediaDescription,
                    dialogInfo.getDynamicMediaPayloadTypeMap());
            dialogCollection.replace(dialogInfo);

            Response response;
            try {
                response = getSimpleSipStack().getMessageFactory().createResponse(Response.OK,
                        serverTransaction.getRequest());
            } catch (ParseException e) {
                throw new StackException(e.getMessage(), e);
            }
            getSimpleSipStack().addContactHeader(response, dialogInfo.getSipUserName());
            getSimpleSipStack().setContent(response, SimpleSipStack.CONTENT_TYPE_APPLICATION,
                    SimpleSipStack.CONTENT_SUBTYPE_SDP, dialogInfo.getSessionDescription().toString());
            getDialogBeanHelper().sendResponse(response, serverTransaction);
        }

        public String getResourceId() {
            return dialogId;
        }
    };
    getConcurrentUpdateManager().executeConcurrentUpdate(concurrentUpdateBlock);
}

From source file:org.apache.directory.fortress.core.AuditMgrConsole.java

/**
 * @param list/*from w  w  w.  j  a v  a  2 s.co m*/
 */
void printAuthZReport(List<AuthZ> list) {
    ReaderUtil.clearScreen();
    if (list != null && list.size() > 0) {
        int ctr = 0;
        for (AuthZ authZ : list) {
            /*
            public class AuthZ
            {
            private String createTimestamp;
            private String creatorsName;
            private String entryCSN;
            private String entryDN;
            private String entryUUID;
            private String hasSubordinates;
            private String modifiersName;
            private String modifyTimestamp;
            private String objectClass;
            private String reqAttr;
            private String reqAttrsOnly;
            private String reqAuthzID;
            private String reqControls;
            private String reqDN;
            private String reqDerefAliases;
            private String reqEnd;
            private String reqEntries;
            private String reqFilter;
            private String reqResult;
            private String reqScope;
            private String reqSession;
            private String reqSizeLimit;
            private String reqStart;
            private String reqTimeLimit;
            private String reqType;
            private String structuralObjectClass;
            private String subschemaSubentry;
            */
            //System.out.println("**********************************");
            System.out.println("AUTHORIZATION AUDIT RECORD " + ctr++);
            System.out.println("***************************************");
            Date aDate = null;
            try {
                aDate = TUtil.decodeGeneralizedTime(authZ.getReqEnd());
            } catch (ParseException pe) {
                System.out.println("    Access Time    " + "ParseException=" + pe.getMessage());
            }
            if (aDate != null) {
                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                String formattedDate = formatter.format(aDate);
                System.out.println("    Access Time     " + formattedDate);
            }

            System.out.println("    userId          " + AuditUtil.getAuthZId(authZ.getReqAuthzID()));
            try {
                Permission pOp = getAuthZPerm(authZ);
                System.out.println("    Resource Name   " + pOp.getObjName());
                System.out.println("    Operation       " + pOp.getOpName());
                int rCtr = 0;
                if (pOp.getRoles() != null) {
                    // TODO: fix the NPE that happens here:
                    System.out.println("    Success?        "
                            + authZ.getReqEntries().equals(GlobalIds.AUTHZ_COMPARE_FAILURE_FLAG));
                    for (String role : pOp.getRoles()) {
                        System.out.println("    Role[" + rCtr++ + "]         " + role);
                    }
                }
            } catch (LdapInvalidDnException e) {
                System.out.println("LdapInvalidDnException=" + e);
            }
            //System.out.println("    reqStart        [" + authZ.getReqStart() + "]");
            //System.out.println("    reqEnd          [" + authZ.getReqEnd() + "]");
            System.out.println();
            System.out.println();
            //System.out.println("**********************************");
        }
    } else {
        System.out.println("AuthZ list empty");
    }
}

From source file:com.bt.aloha.dialog.DialogSipBeanBase.java

protected void processReinvite(final Request request, final ServerTransaction serverTransaction,
        final String dialogId) {
    LOG.debug(String.format("Processing REINVITE request for dialog %s", dialogId));
    ConcurrentUpdateBlock concurrentUpdateBlock = new ConcurrentUpdateBlock() {
        public void execute() {
            DialogInfo dialogInfo = getDialogCollection().get(dialogId);
            DialogState dialogState = dialogInfo.getDialogState();
            // TODO: LOW until we see it - letting stuff through on EARLY - how do we make sure an initial ACK processed after a REINVITE
            // does not overwrite session info?
            // perhaps by storing the remote seq number?
            if (dialogState.ordinal() < DialogState.Early.ordinal()) {
                LOG.warn(String.format("Throwing away reinvite for dialog %s, state is %s", dialogId,
                        dialogInfo.getDialogState()));
                return;
            }/*from   w w w.ja va  2  s  . c  o m*/

            if (dialogInfo.getReinviteInProgess().ordinal() > ReinviteInProgress.None.ordinal()) {
                LOG.warn(String.format(
                        "Reinvite already in progress for dialog %s, responding with 491 Request Pending",
                        dialogId));
                Response response;
                try {
                    response = getSimpleSipStack().getMessageFactory().createResponse(Response.REQUEST_PENDING,
                            request);
                } catch (ParseException e) {
                    throw new StackException(e.getMessage(), e);
                }
                getDialogBeanHelper().sendResponse(response, serverTransaction);
                return;
            }

            if (request.getContentLength().getContentLength() == 0) {
                LOG.warn(String.format(
                        "Reinvite received for dialog %s with empty media, responding with 488 Not acceptable here",
                        dialogId));
                Response response;
                try {
                    response = getSimpleSipStack().getMessageFactory()
                            .createResponse(Response.NOT_ACCEPTABLE_HERE, request);
                } catch (ParseException e) {
                    throw new StackException(e.getMessage(), e);
                }
                getDialogBeanHelper().sendResponse(response, serverTransaction);
                return;
            }

            dialogInfo.setReinviteInProgess(ReinviteInProgress.ReceivedReinvite);
            dialogInfo.setInviteServerTransaction(serverTransaction);
            updateDialogInfoFromInviteRequest(dialogInfo, request);

            getDialogCollection().replace(dialogInfo);

            getEventDispatcher().dispatchEvent(getDialogListeners(),
                    new ReceivedDialogRefreshEvent(dialogId, dialogInfo.getRemoteOfferMediaDescription(),
                            dialogInfo.getRemoteContact().getURI().toString(), null, false));
        }

        public String getResourceId() {
            return dialogId;
        }
    };

    getConcurrentUpdateManager().executeConcurrentUpdate(concurrentUpdateBlock);
}

From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java

private void setDateAndTime(String dateTime) {

    if (dateTime != null && !(TextUtils.isEmpty(dateTime))) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyy-MM-dd kk:mm:ss", Locale.US);
        Date date;/* w  ww. j  av a 2s .c  om*/
        try {

            date = dateFormat.parse(dateTime);

            if (date != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMM dd, yyyy");
                view.mPickDate.setText(simpleDateFormat.format(date));

                SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm a");
                view.mPickTime.setText(timeFormat.format(date));

                // Because the API doesn't support dates in diff Locale
                // mode,
                // force
                // it to show time in US
                SimpleDateFormat submitFormat = new SimpleDateFormat("yyy-MM-dd kk:mm:ss", Locale.US);
                mDateToSubmit = submitFormat.format(date);
            } else {
                view.mPickDate.setText(R.string.change_date);
                view.mPickTime.setText(R.string.change_time);
                mDateToSubmit = null;
            }

        } catch (ParseException e) {
            log(e.getMessage());

        }
    }
}

From source file:io.warp10.standalone.StandaloneDeleteHandler.java

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    if (target.equals(Constants.API_ENDPOINT_DELETE)) {
        baseRequest.setHandled(true);/*  www  .j  a va  2  s.  c o  m*/
    } else {
        return;
    }

    //
    // CORS header
    //

    response.setHeader("Access-Control-Allow-Origin", "*");

    long nano = System.nanoTime();

    //
    // Extract DatalogRequest if specified
    //

    String datalogHeader = request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_DATALOG));

    DatalogRequest dr = null;

    boolean forwarded = false;

    if (null != datalogHeader) {
        byte[] bytes = OrderPreservingBase64.decode(datalogHeader.getBytes(Charsets.US_ASCII));

        if (null != datalogPSK) {
            bytes = CryptoUtils.unwrap(datalogPSK, bytes);
        }

        if (null == bytes) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid Datalog header.");
            return;
        }

        TDeserializer deser = new TDeserializer(new TCompactProtocol.Factory());

        try {
            dr = new DatalogRequest();
            deser.deserialize(dr, bytes);
        } catch (TException te) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.getMessage());
            return;
        }

        Map<String, String> labels = new HashMap<String, String>();
        labels.put(SensisionConstants.SENSISION_LABEL_ID, new String(
                OrderPreservingBase64.decode(dr.getId().getBytes(Charsets.US_ASCII)), Charsets.UTF_8));
        labels.put(SensisionConstants.SENSISION_LABEL_TYPE, dr.getType());
        Sensision.update(SensisionConstants.CLASS_WARP_DATALOG_REQUESTS_RECEIVED, labels, 1);

        //
        // Check that the request query string matches the QS in the datalog request
        //

        if (!request.getQueryString().equals(dr.getDeleteQueryString())) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid DatalogRequest.");
            return;
        }

        forwarded = true;
    }

    //
    // TODO(hbs): Extract producer/owner from token
    //

    String token = null != dr ? dr.getToken()
            : request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_TOKENX));

    if (null == token) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Missing token.");
        return;
    }

    WriteToken writeToken;

    try {
        writeToken = Tokens.extractWriteToken(token);
    } catch (WarpScriptException ee) {
        ee.printStackTrace();
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ee.getMessage());
        return;
    }

    String application = writeToken.getAppName();
    String producer = Tokens.getUUID(writeToken.getProducerId());
    String owner = Tokens.getUUID(writeToken.getOwnerId());

    //
    // For delete operations, producer and owner MUST be equal
    //

    if (!producer.equals(owner)) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid write token for deletion.");
        return;
    }

    Map<String, String> sensisionLabels = new HashMap<String, String>();
    sensisionLabels.put(SensisionConstants.SENSISION_LABEL_PRODUCER, producer);

    long count = 0;
    long gts = 0;

    Throwable t = null;
    StringBuilder metas = new StringBuilder();

    //
    // Extract start/end
    //

    String startstr = request.getParameter(Constants.HTTP_PARAM_START);
    String endstr = request.getParameter(Constants.HTTP_PARAM_END);

    //
    // Extract selector
    //

    String selector = request.getParameter(Constants.HTTP_PARAM_SELECTOR);

    String minage = request.getParameter(Constants.HTTP_PARAM_MINAGE);

    if (null != minage) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "Standalone version does not support the '" + Constants.HTTP_PARAM_MINAGE
                        + "' parameter in delete requests.");
        return;
    }

    boolean dryrun = null != request.getParameter(Constants.HTTP_PARAM_DRYRUN);

    File loggingFile = null;
    PrintWriter loggingWriter = null;

    //
    // Open the logging file if logging is enabled
    //

    if (null != loggingDir) {
        long nanos = null != dr ? dr.getTimestamp() : TimeSource.getNanoTime();
        StringBuilder sb = new StringBuilder();
        sb.append(Long.toHexString(nanos));
        sb.insert(0, "0000000000000000", 0, 16 - sb.length());
        sb.append("-");
        if (null != dr) {
            sb.append(dr.getId());
        } else {
            sb.append(datalogId);
        }

        sb.append("-");
        sb.append(dtf.print(nanos / 1000000L));
        sb.append(Long.toString(1000000L + (nanos % 1000000L)).substring(1));
        sb.append("Z");

        if (null == dr) {
            dr = new DatalogRequest();
            dr.setTimestamp(nanos);
            dr.setType(Constants.DATALOG_DELETE);
            dr.setId(datalogId);
            dr.setToken(token);
            dr.setDeleteQueryString(request.getQueryString());
        }

        if (null != dr && (!forwarded || (forwarded && this.logforwarded))) {
            //
            // Serialize the request
            //

            TSerializer ser = new TSerializer(new TCompactProtocol.Factory());

            byte[] encoded;

            try {
                encoded = ser.serialize(dr);
            } catch (TException te) {
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.getMessage());
                return;
            }

            if (null != this.datalogPSK) {
                encoded = CryptoUtils.wrap(this.datalogPSK, encoded);
            }

            encoded = OrderPreservingBase64.encode(encoded);

            loggingFile = new File(loggingDir, sb.toString());
            loggingWriter = new PrintWriter(new FileWriterWithEncoding(loggingFile, Charsets.UTF_8));

            //
            // Write request
            //

            loggingWriter.println(new String(encoded, Charsets.US_ASCII));
        }
    }

    boolean validated = false;

    try {
        if (null == producer || null == owner) {
            response.sendError(HttpServletResponse.SC_FORBIDDEN, "Invalid token.");
            return;
        }

        //
        // Build extra labels
        //

        Map<String, String> extraLabels = new HashMap<String, String>();
        //
        // Only set owner and potentially app, producer may vary
        //      
        extraLabels.put(Constants.OWNER_LABEL, owner);
        // FIXME(hbs): remove me
        if (null != application) {
            extraLabels.put(Constants.APPLICATION_LABEL, application);
            sensisionLabels.put(SensisionConstants.SENSISION_LABEL_APPLICATION, application);
        }

        boolean hasRange = false;

        long start = Long.MIN_VALUE;
        long end = Long.MAX_VALUE;

        if (null != startstr) {
            if (null == endstr) {
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "Both " + Constants.HTTP_PARAM_START + " and " + Constants.HTTP_PARAM_END
                                + " should be defined.");
                return;
            }
            if (startstr.contains("T")) {
                start = fmt.parseDateTime(startstr).getMillis() * Constants.TIME_UNITS_PER_MS;
            } else {
                start = Long.valueOf(startstr);
            }
        }

        if (null != endstr) {
            if (null == startstr) {
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "Both " + Constants.HTTP_PARAM_START + " and " + Constants.HTTP_PARAM_END
                                + " should be defined.");
                return;
            }
            if (endstr.contains("T")) {
                end = fmt.parseDateTime(endstr).getMillis() * Constants.TIME_UNITS_PER_MS;
            } else {
                end = Long.valueOf(endstr);
            }
        }

        if (Long.MIN_VALUE == start && Long.MAX_VALUE == end
                && null == request.getParameter(Constants.HTTP_PARAM_DELETEALL)) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Parameter "
                    + Constants.HTTP_PARAM_DELETEALL + " should be set when deleting a full range.");
            return;
        }

        if (Long.MIN_VALUE != start || Long.MAX_VALUE != end) {
            hasRange = true;
        }

        if (start > end) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Invalid time range specification.");
            return;
        }

        //
        // Extract the class and labels selectors
        // The class selector and label selectors are supposed to have
        // values which use percent encoding, i.e. explicit percent encoding which
        // might have been re-encoded using percent encoding when passed as parameter
        //
        //

        Matcher m = EgressFetchHandler.SELECTOR_RE.matcher(selector);

        if (!m.matches()) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }

        String classSelector = URLDecoder.decode(m.group(1), "UTF-8");
        String labelsSelection = m.group(2);

        Map<String, String> labelsSelectors;

        try {
            labelsSelectors = GTSHelper.parseLabelsSelectors(labelsSelection);
        } catch (ParseException pe) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, pe.getMessage());
            return;
        }

        validated = true;

        //
        // Force 'producer'/'owner'/'app' from token
        //

        labelsSelectors.putAll(extraLabels);

        List<Metadata> metadatas = null;

        List<String> clsSels = new ArrayList<String>();
        List<Map<String, String>> lblsSels = new ArrayList<Map<String, String>>();
        clsSels.add(classSelector);
        lblsSels.add(labelsSelectors);

        metadatas = directoryClient.find(clsSels, lblsSels);

        response.setStatus(HttpServletResponse.SC_OK);
        response.setContentType("text/plain");

        PrintWriter pw = response.getWriter();
        StringBuilder sb = new StringBuilder();

        for (Metadata metadata : metadatas) {
            //
            // Remove from DB
            //

            if (!hasRange) {
                if (!dryrun) {
                    this.directoryClient.unregister(metadata);
                }
            }

            //
            // Remove data
            //

            long localCount = 0;

            if (!dryrun) {
                localCount = this.storeClient.delete(writeToken, metadata, start, end);
            }

            count += localCount;

            sb.setLength(0);
            GTSHelper.metadataToString(sb, metadata.getName(), metadata.getLabels());

            if (metadata.getAttributesSize() > 0) {
                GTSHelper.labelsToString(sb, metadata.getAttributes());
            } else {
                sb.append("{}");
            }

            pw.write(sb.toString());
            pw.write("\r\n");
            metas.append(sb);
            metas.append("\n");
            gts++;

            // Log detailed metrics for this GTS owner and app
            Map<String, String> labels = new HashMap<>();
            labels.put(SensisionConstants.SENSISION_LABEL_OWNER,
                    metadata.getLabels().get(Constants.OWNER_LABEL));
            labels.put(SensisionConstants.SENSISION_LABEL_APPLICATION,
                    metadata.getLabels().get(Constants.APPLICATION_LABEL));
            Sensision.update(
                    SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_DATAPOINTS_PEROWNERAPP,
                    labels, localCount);
        }
    } catch (Exception e) {
        t = e;
        throw e;
    } finally {
        if (null != loggingWriter) {
            Map<String, String> labels = new HashMap<String, String>();
            labels.put(SensisionConstants.SENSISION_LABEL_ID, new String(
                    OrderPreservingBase64.decode(dr.getId().getBytes(Charsets.US_ASCII)), Charsets.UTF_8));
            labels.put(SensisionConstants.SENSISION_LABEL_TYPE, dr.getType());
            Sensision.update(SensisionConstants.CLASS_WARP_DATALOG_REQUESTS_LOGGED, labels, 1);

            loggingWriter.close();
            if (validated) {
                loggingFile.renameTo(new File(loggingFile.getAbsolutePath() + DatalogForwarder.DATALOG_SUFFIX));
            } else {
                loggingFile.delete();
            }
        }

        Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_REQUESTS,
                sensisionLabels, 1);
        Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_GTS, sensisionLabels,
                gts);
        Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_DATAPOINTS,
                sensisionLabels, count);
        Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_TIME_US,
                sensisionLabels, (System.nanoTime() - nano) / 1000);

        LoggingEvent event = LogUtil.setLoggingEventAttribute(null, LogUtil.DELETION_TOKEN, token);
        event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_SELECTOR, selector);
        event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_START, startstr);
        event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_END, endstr);
        event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_METADATA, metas.toString());
        event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_COUNT, Long.toString(count));
        event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_GTS, Long.toString(gts));

        LogUtil.addHttpHeaders(event, request);

        if (null != t) {
            LogUtil.setLoggingEventStackTrace(null, LogUtil.STACK_TRACE, t);
        }

        LOG.info(LogUtil.serializeLoggingEvent(this.keyStore, event));
    }

    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:org.owasp.webscarab.plugin.sessionid.swing.SessionIDPanel.java

private void fetchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fetchButtonActionPerformed
    try {/*from  ww  w  .  j  av  a2  s  . c o  m*/
        Request request = _requestPanel.getRequest();
        if (request == null) {
            _logger.warning("Request was null in fetch request");
            return;
        }
        String name = nameTextField.getText();
        String regex = regexTextField.getText();
        int count = ((Integer) sampleSpinner.getValue()).intValue();
        try {
            _sa.fetch(request, name, regex, count);
        } catch (PatternSyntaxException pse) {
            JOptionPane.showMessageDialog(this, pse.getMessage(), "Pattern Syntax Exception",
                    JOptionPane.WARNING_MESSAGE);
        }
    } catch (MalformedURLException mue) {
        JOptionPane.showMessageDialog(this, new String[] { "The URL requested is malformed", mue.getMessage() },
                "Malformed URL", JOptionPane.ERROR_MESSAGE);
    } catch (ParseException pe) {
        JOptionPane.showMessageDialog(this, new String[] { "The request is malformed", pe.getMessage() },
                "Malformed Request", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:org.egov.collection.web.actions.citizen.OnlineReceiptAction.java

/**
 * This method is invoked for manually reconciling online payments. If a payment is reconciled as a Success Payment, the
 * receipt is created, the receipt is marked as APPROVED , the payment is marked as SUCCESS, and the voucher is created. If a
 * payment is reconciled as To Be Refunded or Refunded, the transaction details are persisted, receipt is marked as FAILED and
 * the payment is marked as TO BE REFUNDED/REFUNDED respectively. The billing system is updated about all the payments that
 * have been successful./*from ww  w. j  a  va2  s.c  o  m*/
 *
 * @return
 */
@ValidationErrorPage(value = "reconresult")
@Action(value = "/citizen/onlineReceipt-reconcileOnlinePayment")
public String reconcileOnlinePayment() {

    final ReceiptHeader[] receipts = new ReceiptHeader[selectedReceipts.length];

    Date transDate = null;

    errors.clear();

    for (int i = 0; i < getSelectedReceipts().length; i++) {
        receipts[i] = receiptHeaderService.findById(selectedReceipts[i], false);

        final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
        if (getTransactionDate()[i] != null) {
            final String vdt = getTransactionDate()[i];
            try {
                transDate = sdf.parse(vdt);
            } catch (final ParseException e) {
                LOGGER.debug("Error occured while parsing date " + e.getMessage());
            }
        }

        if (getStatusCode()[i].equals(CollectionConstants.ONLINEPAYMENT_STATUS_CODE_SUCCESS)) {
            final List<ReceiptDetail> existingReceiptDetails = new ArrayList<>(0);

            for (final ReceiptDetail receiptDetail : receipts[i].getReceiptDetails())
                if (!FinancialsUtil.isRevenueAccountHead(receiptDetail.getAccounthead(),
                        chartOfAccountsHibernateDAO.getBankChartofAccountCodeList(), persistenceService)) {
                    final ReceiptDetail newReceiptDetail = new ReceiptDetail();
                    if (receiptDetail.getOrdernumber() != null)
                        newReceiptDetail.setOrdernumber(receiptDetail.getOrdernumber());
                    if (receiptDetail.getDescription() != null)
                        newReceiptDetail.setDescription(receiptDetail.getDescription());
                    if (receiptDetail.getIsActualDemand() != null)
                        newReceiptDetail.setIsActualDemand(receiptDetail.getIsActualDemand());
                    if (receiptDetail.getFunction() != null)
                        newReceiptDetail.setFunction(receiptDetail.getFunction());
                    if (receiptDetail.getCramountToBePaid() != null)
                        newReceiptDetail.setCramountToBePaid(receiptDetail.getCramountToBePaid());
                    newReceiptDetail.setCramount(receiptDetail.getCramount());
                    newReceiptDetail.setAccounthead(receiptDetail.getAccounthead());
                    newReceiptDetail.setDramount(receiptDetail.getDramount());
                    existingReceiptDetails.add(newReceiptDetail);
                }
            final List<ReceiptDetail> reconstructedList = collectionsUtil.reconstructReceiptDetail(receipts[i],
                    existingReceiptDetails);

            ReceiptDetail debitAccountDetail = null;
            if (reconstructedList != null) {
                DebitAccountHeadDetailsService debitAccountHeadService = (DebitAccountHeadDetailsService) beanProvider
                        .getBean(collectionsUtil.getBeanNameForDebitAccountHead());
                debitAccountDetail = debitAccountHeadService.addDebitAccountHeadDetails(
                        receipts[i].getTotalAmount(), receipts[i], BigDecimal.ZERO,
                        receipts[i].getTotalAmount(), CollectionConstants.INSTRUMENTTYPE_ONLINE);
            }

            receiptHeaderService.reconcileOnlineSuccessPayment(receipts[i], transDate, getTransactionId()[i],
                    receipts[i].getTotalAmount(), null, reconstructedList, debitAccountDetail);

            LOGGER.debug("Manually reconciled a success online payment");
        }

        if (CollectionConstants.ONLINEPAYMENT_STATUS_CODE_TO_BE_REFUNDED.equals(getStatusCode()[i])
                || CollectionConstants.ONLINEPAYMENT_STATUS_CODE_REFUNDED.equals(getStatusCode()[i])) {
            receipts[i].setStatus(
                    collectionsUtil.getReceiptStatusForCode(CollectionConstants.RECEIPT_STATUS_CODE_FAILED));

            receipts[i].getOnlinePayment().setTransactionNumber(getTransactionId()[i]);
            receipts[i].getOnlinePayment().setTransactionAmount(receipts[i].getTotalAmount());
            receipts[i].getOnlinePayment().setTransactionDate(transDate);
            receipts[i].getOnlinePayment().setRemarks(getRemarks()[i]);

            // set online payment status as TO BE REFUNDED/REFUNDED
            if (getStatusCode()[i].equals(CollectionConstants.ONLINEPAYMENT_STATUS_CODE_TO_BE_REFUNDED))
                receipts[i].getOnlinePayment()
                        .setStatus(collectionsUtil.getStatusForModuleAndCode(
                                CollectionConstants.MODULE_NAME_ONLINEPAYMENT,
                                CollectionConstants.ONLINEPAYMENT_STATUS_CODE_TO_BE_REFUNDED));
            else
                receipts[i].getOnlinePayment()
                        .setStatus(collectionsUtil.getStatusForModuleAndCode(
                                CollectionConstants.MODULE_NAME_ONLINEPAYMENT,
                                CollectionConstants.ONLINEPAYMENT_STATUS_CODE_REFUNDED));

            receiptHeaderService.persist(receipts[i]);

            LOGGER.debug("Manually reconciled an online payment to " + getStatusCode()[i] + " state.");
        }
    }
    return RECONRESULT;
}

From source file:edu.hawaii.soest.pacioos.text.SimpleTextSource.java

/**
 * Send the sample to the DataTurbine//from   w w  w  .java 2 s  .c o m
 * 
 * @param sample the ASCII sample string to send
 * @throws IOException
 * @throws SAPIException
 */
public int sendSample(String sample) throws IOException, SAPIException {
    int numberOfChannelsFlushed = 0;

    // add a channel of data that will be pushed to the server.  
    // Each sample will be sent to the Data Turbine as an rbnb frame.
    ChannelMap rbnbChannelMap = new ChannelMap();
    Date sampleDate = new Date();
    try {
        sampleDate = getSampleDate(sample);

    } catch (ParseException e) {
        log.warn("A sample date couldn't be parsed from the sample.  Using the current date."
                + " the error message was: " + e.getMessage());
    }
    long sampleTimeAsSecondsSinceEpoch = (sampleDate.getTime() / 1000L);

    // send the sample to the data turbine
    rbnbChannelMap.PutTime((double) sampleTimeAsSecondsSinceEpoch, 0d);
    int channelIndex = rbnbChannelMap.Add(getChannelName());
    rbnbChannelMap.PutMime(channelIndex, "text/plain");
    rbnbChannelMap.PutDataAsString(channelIndex, sample);

    try {
        numberOfChannelsFlushed = getSource().Flush(rbnbChannelMap);
        log.info("Sample: " + sample.substring(0, sample.length() - this.recordDelimiters.length)
                + " sent data to the DataTurbine.");
        rbnbChannelMap.Clear();
        // in the event we just lost the network, sleep, try again
        while (numberOfChannelsFlushed < 1) {
            log.debug("No channels flushed, trying again in 10 seconds.");
            Thread.sleep(10000L);
            numberOfChannelsFlushed = getSource().Flush(rbnbChannelMap, true);

        }

    } catch (InterruptedException e) {
        e.printStackTrace();

    }

    return numberOfChannelsFlushed;
}

From source file:org.ejbca.ui.web.admin.configuration.EjbcaWebBean.java

/**
 * Convert a the format "yyyy-MM-dd HH:mm" with implied TimeZone UTC to a more user friendly "yyyy-MM-dd HH:mm:ssZZ". If it is a relative date we
 * return it as it was. If we fail to parse the stored date we return an error-string followed by the stored value.
 *///from   www . j  a va  2 s  .com
public String getISO8601FromImpliedUTCOrRelative(final String dateString) {
    if (!isRelativeDateTime(dateString)) {
        try {
            return getISO8601FromImpliedUTC(dateString);
        } catch (ParseException e) {
            log.debug(e.getMessage());
            // If we somehow managed to store an invalid date, we want to give the admin the option
            // to correct this. If we just throw an Exception here it would not be possible.
            return "INVALID: " + dateString;
        }
    }
    return dateString;
}