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.owasp.webscarab.plugin.sessionid.swing.SessionIDPanel.java

private void testButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_testButtonActionPerformed
    try {/* w  w w .  j a va2 s . c o  m*/
        final Request request = _requestPanel.getRequest();
        if (request == null) {
            return;
        }
        testButton.setEnabled(false);
        final Component parent = this;
        new SwingWorker() {
            public Object construct() {
                try {
                    _sa.setRequest(request);
                    _sa.fetchResponse();
                    return _sa.getResponse();
                } catch (IOException ioe) {
                    return ioe;
                }
            }

            //Runs on the event-dispatching thread.
            public void finished() {
                Object obj = getValue();
                if (obj instanceof Response) {
                    Response response = (Response) getValue();
                    if (response != null) {
                        _responsePanel.setResponse(response);
                        String name = nameTextField.getText();
                        String regex = regexTextField.getText();
                        try {
                            Map<String, SessionID> ids = _sa.getIDsFromResponse(response, name, regex);
                            String[] keys = ids.keySet().toArray(new String[0]);
                            for (int i = 0; i < keys.length; i++) {
                                SessionID id = ids.get(keys[i]);
                                keys[i] = keys[i] + " = " + id.getValue();
                            }
                            if (keys.length == 0)
                                keys = new String[] { "No session identifiers found!" };
                            JOptionPane.showMessageDialog(parent, keys, "Extracted Sessionids",
                                    JOptionPane.INFORMATION_MESSAGE);
                        } catch (PatternSyntaxException pse) {
                            JOptionPane.showMessageDialog(parent, pse.getMessage(), "Patter Syntax Exception",
                                    JOptionPane.WARNING_MESSAGE);
                        }
                    }
                } else if (obj instanceof Exception) {
                    JOptionPane.showMessageDialog(null,
                            new String[] { "Error fetching response: ", obj.toString() }, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    _logger.severe("Exception fetching response: " + obj);
                }
                testButton.setEnabled(true);
            }
        }.start();
    } 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:no.met.jtimeseries.chart.ChartPlotter.java

private Map<Long, String> getDomainMarkersWithLabel(List<Date> time, TimeZone timeZone, Locale locale) {
    Map<Long, String> markers = new HashMap<Long, String>();
    for (Date date : time) {
        SimpleDateFormat dateFormat;
        //long term and short time have different time format marker
        if (Utility.hourDifference(time.get(0), time.get(time.size() - 1)) < 50) {
            // short term
            dateFormat = new SimpleDateFormat("EEEE d. MMM.", locale);
        } else {//  ww  w.  ja v  a 2s  .c o m
            // long term
            dateFormat = new SimpleDateFormat("EEE. d. MMM.", locale);
        }
        dateFormat.setTimeZone(timeZone);
        if (isDayMarker(date, timeZone)) {
            SimpleDateFormat utcFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z");
            utcFormat.setTimeZone(timeZone);
            try {
                Date dateInUTC = utcFormat.parse(utcFormat.format(date));
                markers.put(dateInUTC.getTime(), dateFormat.format(date));
            } catch (ParseException ex) {
                LogUtils.logException(logger, ex.getMessage(), ex);
            }

        }
    }
    return markers;
}

From source file:org.apache.gobblin.salesforce.SalesforceExtractor.java

@Override
public long getHighWatermark(CommandOutput<?, ?> response, String watermarkColumn, String format)
        throws HighWatermarkException {
    log.info("Get high watermark from salesforce");

    String output;/*from   w ww  . j av  a  2s  .  c om*/
    Iterator<String> itr = (Iterator<String>) response.getResults().values().iterator();
    if (itr.hasNext()) {
        output = itr.next();
    } else {
        throw new HighWatermarkException(
                "Failed to get high watermark from salesforce; REST response has no output");
    }

    JsonElement element = GSON.fromJson(output, JsonObject.class);
    long high_ts;
    try {
        JsonObject jsonObject = element.getAsJsonObject();
        JsonArray jsonArray = jsonObject.getAsJsonArray("records");
        if (jsonArray.size() == 0) {
            return -1;
        }

        String value = jsonObject.getAsJsonArray("records").get(0).getAsJsonObject().get(watermarkColumn)
                .getAsString();
        if (format != null) {
            SimpleDateFormat inFormat = new SimpleDateFormat(format);
            Date date = null;
            try {
                date = inFormat.parse(value);
            } catch (ParseException e) {
                log.error("ParseException: " + e.getMessage(), e);
            }
            SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
            high_ts = Long.parseLong(outFormat.format(date));
        } else {
            high_ts = Long.parseLong(value);
        }

    } catch (Exception e) {
        throw new HighWatermarkException(
                "Failed to get high watermark from salesforce; error - " + e.getMessage(), e);
    }
    return high_ts;
}

From source file:com.aegiswallet.actions.MainActivity.java

private void doBackupReminder() {

    if (System.currentTimeMillis() - application.lastReminderTime < 60000)
        return;/*from   w w w .ja v a 2 s  .co  m*/

    String lastBackupString = prefs.getString(Constants.LAST_BACKUP_DATE, null);
    int lastBackupNumAddresses = prefs.getInt(Constants.LAST_BACKUP_NUM_ADDRESSES, 0);

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.backup_reminder_prompt);

    TextView backupText = (TextView) dialog.findViewById(R.id.backup_reminder_prompt_text);

    Button cancelButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    final Button okayButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_ok_button);

    okayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();

            if (nfcEnabled) {
                Intent intent = new Intent(context, NFCActivity.class);
                intent.putExtra("nfc_action", "backup");
                startActivity(intent);
            } else
                application.showPasswordPrompt(context, Constants.ACTION_BACKUP);
        }
    });

    try {

        if (dialog.isShowing())
            return;

        if (lastBackupString != null) {
            Date lastBackupDate = Constants.backupDateFormat.parse(lastBackupString);
            long currentDate = System.currentTimeMillis();
            long difference = currentDate - lastBackupDate.getTime();

            long days = TimeUnit.MILLISECONDS.toDays(difference);
            int keyChainSize = wallet.getKeychainSize();

            if (days > 6) {
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();
            } else if (!prefs.contains(Constants.LAST_BACKUP_NUM_ADDRESSES)) {
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();

            } else if (keyChainSize > lastBackupNumAddresses) {
                backupText.setText(getString(R.string.backup_reminder_new_address));
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();
            }

        } else {
            application.lastReminderTime = System.currentTimeMillis();
            dialog.show();
        }

    } catch (ParseException e) {
        Log.d(TAG, e.getMessage());
    }
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

private GerritUserVO transformUserJSONObject(JSONObject j) throws RepositoryException {
    if (j == null) {
        throw new RepositoryException("No data to parse!");
    }//  ww w . j a v a 2s.  c  o  m

    log.debug(String.format("transformJSONObject(j=%s)", j));

    GerritUserVO user = new GerritUserVO();

    user.setId(j.getString(GerritUserVO.JSON_KEY_ACCT_ID));
    user.setEmail(j.getString(GerritUserVO.JSON_KEY_EMAIL));

    String test = j.getString(GerritUserVO.JSON_KEY_INACTIVE);

    user.setActive(test.equals("N"));

    // "2013-10-03 10:44:10.908"'
    String regDate = j.getString(GerritUserVO.JSON_KEY_REG_DATE);

    try {
        Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ENGLISH).parse(regDate);
        user.setRegistrationDate(date);
    } catch (ParseException e) {
        log.debug(e.getMessage());
    }

    return user;
}

From source file:org.gbif.dwca.action.ValidateAction.java

@Override
public String execute() {
    ArchiveLocation archLoc = null;/*from w w w  . java 2  s.  c  om*/
    try {
        if (!StringUtils.isBlank(ifModifiedSince)) {
            ifModifiedSinceDate = DateFormatUtils.ISO_DATE_FORMAT.parse(ifModifiedSince);
            if (ifModifiedSinceDate == null) {
                log.debug("Use conditional get for download if modified since: " + ifModifiedSince);
                return INPUT;
            }
        }

        archLoc = extractArchive();
        if (archLoc == null && status == null) {
            return INPUT;
        }
        if (archLoc != null) {
            extensions = extensionManager.map();
            validateAgainstSchema(archLoc.metaFile);
            validateArchive(archLoc.dwcaFolder);
        }
    } catch (ParseException e) {
        setOffline("Invalid ISO date " + e.getMessage());
    } catch (MalformedURLException e) {
        setOffline("MalformedURLException " + e.getMessage());
    } catch (SocketException e) {
        setOffline(e.getClass().getSimpleName() + " " + e.getMessage());
    } catch (Exception e) {
        log.error("Unknown error when validating archive", e);
        valid = false;
    } finally {
        // cleanup temp files!
        cleanupTempFile(archLoc);
    }

    // store html report
    if (archLoc != null) {
        storeReport();
    }

    return SUCCESS;
}

From source file:files.TestFileDirCleaner.java

private long getCleanDurationBeforeApril2008() {
    String cleanBeforeThisDateStr = "2008-03-30";
    Date cleanBeforeThisDate = null;
    try {//w  ww . j a va  2s. co m
        cleanBeforeThisDate = sdf.parse(cleanBeforeThisDateStr);
    } catch (ParseException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    long cleanAfterThisDuration = System.currentTimeMillis() - cleanBeforeThisDate.getTime();

    return cleanAfterThisDuration / 1000;
}

From source file:org.apache.manifoldcf.crawler.connectors.alfresco.AlfrescoRepositoryConnector.java

private void handleParseException(ParseException e) throws ManifoldCFException {
    throw new ManifoldCFException(
            "Alfresco: Error during parsing date values. This should never happen: " + e.getMessage(), e);
}

From source file:com.basetechnology.s0.agentserver.AgentServer.java

public AgentInstance getAgentInstance(User user, JSONObject agentJson) throws SymbolException, RuntimeException,
        AgentServerException, JSONException, TokenizerException, ParserException {
    // Parse the JSON for the agent instance

    // If we have the user, ignore user from JSON
    if (user == null) {
        String userId = agentJson.optString("user");
        if (userId == null || userId.trim().length() == 0)
            throw new AgentServerException("Agent instance user id ('user') is missing");
        user = getUser(userId);/*  w w w .j  a v  a 2  s . co  m*/
        if (user == User.noUser)
            throw new AgentServerException("Agent instance user id does not exist: '" + userId + "'");
    }

    // Parse the agent instance name
    String agentInstanceName = agentJson.optString("name");
    if (agentInstanceName == null || agentInstanceName.trim().length() == 0)
        throw new AgentServerException("Agent instance name ('name') is missing");

    // Parse the agent definition name
    String agentDefinitionName = agentJson.optString("definition");
    if (agentDefinitionName == null || agentDefinitionName.trim().length() == 0)
        throw new AgentServerException(
                "Agent instance definition name ('definition') is missing for user '" + user.id + "'");
    String agentDescription = agentJson.optString("description");
    if (agentDescription == null || agentDescription.trim().length() == 0)
        agentDescription = "";
    log.info("Adding new agent instance named: " + agentInstanceName + " for agent definition '"
            + agentDefinitionName + "' for user: " + user.id);
    AgentInstanceList agentMap = agentInstances.get(user.id);
    if (agentMap == null) {
        agentMap = new AgentInstanceList();
        agentInstances.add(user.id, agentMap);
    }

    // Check if referenced agent definition exists
    AgentDefinitionList userAgentDefinitions = agentDefinitions.get(user.id);
    if (userAgentDefinitions == null)
        throw new AgentServerException(
                "Agent instance '" + agentInstanceName + "' references agent definition '" + agentDefinitionName
                        + "' which does not exist for user '" + user.id + "'");
    AgentDefinition agentDefinition = agentDefinitions.nameValueMap.get(user.id).value.get(agentDefinitionName);
    if (agentDefinition == null)
        throw new AgentServerException(
                "Agent instance '" + agentInstanceName + "' references agent definition '" + agentDefinitionName
                        + "' which does not exist for user '" + user.id + "'");

    // Parse the agent instance parameter values
    String invalidParameterNames = "";
    SymbolManager symbolManager = new SymbolManager();
    SymbolTable symbolTable = symbolManager.getSymbolTable("parameter_values");
    JSONObject parameterValuesJson = null;
    SymbolValues parameterValues = null;
    if (agentJson.has("parameter_values")) {
        // Parse the parameter values
        parameterValuesJson = agentJson.optJSONObject("parameter_values");
        parameterValues = SymbolValues.fromJson(symbolTable, parameterValuesJson);

        // Validate that they are all valid agent definition parameters
        Map<String, Value> treeMap = new TreeMap<String, Value>();
        for (Symbol symbol : parameterValues)
            treeMap.put(symbol.name, null);
        for (String parameterName : treeMap.keySet())
            if (!agentDefinition.parameters.containsKey(parameterName))
                invalidParameterNames += (invalidParameterNames.length() > 0 ? ", " : "") + parameterName;
        if (invalidParameterNames.length() > 0)
            throw new AgentServerException("Parameter names for agent instance " + agentInstanceName
                    + " are not defined for referenced agent definition " + agentDefinitionName + ": "
                    + invalidParameterNames);
    }

    // Check if instance of named agent definition with specified parameters exists yet
    if (agentMap.getAgentInstance(user, agentDefinition, parameterValues) != null)
        throw new AgentServerException("Agent instance name already exists: '" + agentInstanceName
                + "' with paramters " + parameterValues.toString());

    String triggerIntervalExpression = agentJson.optString("trigger_interval",
            AgentDefinition.DEFAULT_TRIGGER_INTERVAL_EXPRESSION);
    String reportingIntervalExpression = agentJson.optString("reporting_interval",
            AgentDefinition.DEFAULT_REPORTING_INTERVAL_EXPRESSION);

    boolean publicOutput = agentJson.optBoolean("public_output", false);

    int limitInstanceStatesStored = agentJson.optInt("limit_instance_states_stored", -1);

    boolean enabled = agentJson.optBoolean("enabled", true);

    String created = agentJson.optString("created", null);
    long timeCreated = -1;
    try {
        timeCreated = created != null ? DateUtils.parseRfcString(created) : -1;
    } catch (ParseException e) {
        throw new AgentServerException("Unable to parse created date ('" + created + "') - " + e.getMessage());
    }
    String modified = agentJson.optString("modified", null);
    long timeModified = -1;
    try {
        timeModified = modified != null ? DateUtils.parseRfcString(modified) : -1;
    } catch (ParseException e) {
        throw new AgentServerException(
                "Unable to parse modified date ('" + modified + "') - " + e.getMessage());
    }

    AgentInstance agentInstance = agentMap.put(user, agentDefinition, agentInstanceName, agentDescription,
            parameterValues, triggerIntervalExpression, reportingIntervalExpression, publicOutput,
            limitInstanceStatesStored, enabled, timeCreated, timeModified);

    // Persist the new agent instance
    persistence.put(agentInstance);

    // Return the created/shared agent instance
    return agentInstance;
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

private GerritChangeVO transformChangeJSONObject(JSONObject j) throws RepositoryException {
    if (j == null) {
        throw new RepositoryException("No data to parse!");
    }/*from www  .  j a  v  a2s.  c  om*/

    log.debug(String.format("transformJSONObject(j=%s)", j));

    GerritChangeVO info = new GerritChangeVO();

    info.setProject(j.getString(GerritChangeVO.JSON_KEY_PROJECT));
    info.setBranch(j.getString(GerritChangeVO.JSON_KEY_BRANCH));
    info.setId(j.getString(GerritChangeVO.JSON_KEY_ID));
    info.setNumber(j.getInt(GerritChangeVO.JSON_KEY_NUMBER));
    info.setSubject(j.getString(GerritChangeVO.JSON_KEY_SUBJECT));

    JSONObject owner = j.getJSONObject(GerritChangeVO.JSON_KEY_OWNER);

    if (owner.containsKey(GerritChangeVO.JSON_KEY_NAME))
        info.setOwnerName(owner.getString(GerritChangeVO.JSON_KEY_NAME));

    if (owner.containsKey(GerritChangeVO.JSON_KEY_USERNAME))
        info.setOwnerUserName(owner.getString(GerritChangeVO.JSON_KEY_USERNAME));

    if (owner.containsKey(GerritChangeVO.JSON_KEY_EMAIL))
        info.setOwnerEmail(owner.getString(GerritChangeVO.JSON_KEY_EMAIL));

    info.setUrl(j.getString(GerritChangeVO.JSON_KEY_URL));

    Integer createdOne = j.getInt(GerritChangeVO.JSON_KEY_CREATED_ON);
    info.setCreatedOn(new Date(createdOne.longValue() * 1000));
    Integer lastUpdate = j.getInt(GerritChangeVO.JSON_KEY_LAST_UPDATE);
    info.setLastUpdate(new Date(lastUpdate.longValue() * 1000));

    info.setOpen(j.getBoolean(GerritChangeVO.JSON_KEY_OPEN));
    info.setStatus(j.getString(GerritChangeVO.JSON_KEY_STATUS));

    JSONObject cp = j.getJSONObject(GerritChangeVO.JSON_KEY_CURRENT_PATCH_SET);
    try {
        assignPatchSet(info, cp, true);

        List<JSONObject> patchSets = j.getJSONArray(GerritChangeVO.JSON_KEY_PATCH_SET);

        for (JSONObject p : patchSets) {
            assignPatchSet(info, p, false);
        }
    } catch (ParseException e) {
        throw new RepositoryException(e.getMessage());
    }

    log.debug(String.format("Object Transformed change=%s", info.toString()));

    return info;
}