List of usage examples for java.lang NullPointerException getMessage
public String getMessage()
From source file:com.github.fge.jsonschema.core.report.ProcessingMessageTest.java
@Test public void cannotSetNullExceptionProvider() { try {//from w w w . j a v a 2s. c o m new ProcessingMessage().setExceptionProvider(null); fail("No exception thrown!!"); } catch (NullPointerException e) { assertEquals(e.getMessage(), BUNDLE.getMessage("processing.nullExceptionProvider")); } }
From source file:com.github.fge.jsonschema.core.report.ProcessingMessageTest.java
@Test public void cannoSetThresholdToNull() { final ProcessingMessage msg = new ProcessingMessage(); try {// w w w .j av a 2 s. c o m msg.setLogLevel(null); fail("No exception thrown!"); } catch (NullPointerException e) { assertEquals(e.getMessage(), BUNDLE.getMessage("processing.nullLevel")); } }
From source file:org.openmrs.module.rheapocadapter.handler.ClientRegistryService.java
/** * @see org.openmrs.module.rheapocadapter.service.ClientRegistryService#registerNewPatient(java.util.List) *//*from w w w .j a v a2s .c om*/ public String registerNewPatients(List<Patient> patients) { try { String result = ""; MessageTransformer messageTransformer = new HL7MessageTransformer(); String message = ""; String patientIds = ""; for (Patient patient : patients) { message += (String) messageTransformer.generateMessage(patient, "Create"); if (patientIds != "") { patientIds += "," + patient.getPatientId(); } else { patientIds += patient.getPatientId(); } } if ("".equals(message) || message.equals(null)) { return "Register failed due to message creation, Contact Administrator"; } log.error("Message to send " + message); TransactionUtil.setCreator(patients.get(0).getCreator()); String[] methd = new String[] { "POST", "RegisterNew" }; TreeMap<String, String> parameters = new TreeMap<String, String>(); Transaction item = requestHandler.sendRequest(methd, message, parameters); if (item instanceof ArchiveTransaction) { item.setMessage("Saving patients with Ids" + patientIds + " Succeded"); result = "Register succeded"; } else if (item instanceof ProcessingTransaction) { item.setMessage(patientIds); result = "Register failed, try again later"; } else if (item instanceof ErrorTransaction) { result = "Register failed, Contact Administrator"; } response.handleResponse(item); return result; } catch (NullPointerException e) { log.error(e.getMessage()); return ""; } }
From source file:org.mobicents.servlet.restcomm.http.OutgoingCallerIdsEndpoint.java
protected Response putOutgoingCallerId(final String accountSid, final MultivaluedMap<String, String> data, final MediaType responseType) { secure(accountsDao.getAccount(accountSid), "RestComm:Create:OutgoingCallerIds"); try {//w ww . ja v a 2s .c o m validate(data); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } final OutgoingCallerId outgoingCallerId = createFrom(new Sid(accountSid), data); dao.addOutgoingCallerId(outgoingCallerId); if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(outgoingCallerId), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(outgoingCallerId); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }
From source file:eu.learnpad.simulator.mon.impl.ComplexEventProcessorImpl.java
private KnowledgeBase createKnowledgeBase() { try {/*from ww w .j a v a2 s . c o m*/ KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); config.setOption(EventProcessingOption.STREAM); /* Using knowledge builder to create a knowledgePackage using provided resources (drl file) * after the creation the knowledgePackage contained into the knowledge builder will be putted * into the knowledgeBase using the method addKnowledgePackages(knowledgeBuilder.getKnowledgePackages()) */ knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); byte[] firstRuleToLoadByteArray = Manager .ReadTextFromFile(System.getProperty("user.dir") + "/configFiles/startupRule.drl").getBytes(); Resource drlToLoad = ResourceFactory.newByteArrayResource(firstRuleToLoadByteArray); try { knowledgeBuilder.add(drlToLoad, ResourceType.DRL); } catch (Exception asd) { System.out.println(asd.getMessage()); } KnowledgeBuilderErrors errors = knowledgeBuilder.getErrors(); if (errors.size() > 0) { for (KnowledgeBuilderError error : errors) { System.err.println(error); } throw new IllegalArgumentException("Could not parse knowledge."); } knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(config); knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages()); return knowledgeBase; } catch (NullPointerException e) { System.out.println(e.getMessage()); System.out.println(e.getCause()); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), e.getMessage()); return null; } }
From source file:org.wso2.carbon.mediator.bam.StreamDefinitionBuilder.java
private void addPropertyPayloadToPayloadDataList(List<Attribute> attributes) throws BamMediatorException { try {/*from www.j a v a 2 s . c om*/ List<Property> properties = this.streamConfiguration.getProperties(); if (properties != null) { for (Property property : properties) { if (property.getKey() != null && property.getType() != null) { attributes.add(new Attribute(property.getKey(), this.resolveTypes(property.getType()))); } } } } catch (NullPointerException e) { String errorMsg = "Undefined key or type in Stream Property. " + e.getMessage(); log.error(errorMsg, e); throw new BamMediatorException(errorMsg, e); } catch (Exception e) { String errorMsg = "Error occurred while adding the Property Fields to Payload Data list. " + e.getMessage(); log.error(errorMsg, e); throw new BamMediatorException(errorMsg, e); } }
From source file:edu.du.penrose.systems.fedoraApp.util.MetsBatchFileSplitter.java
/** * Parse the batch ingest command line and store the command in the returned BatchIngestOption object. * /* w w w .jav a 2 s .c om*/ * @param ingestOptions * @param batchCommandFile * @return the passed in ingestOptions * @throws FatalException */ public static BatchIngestOptions setCommandLineOptions(BatchIngestOptions ingestOptions, File batchCommandFile) throws FatalException { FileInputStream batchFileInputStream = null; DataInputStream batchFileDataInputStream = null; BufferedReader batchFileBufferedReader = null; boolean isBatchFile = false; boolean validCommandLine = false; try { batchFileInputStream = new FileInputStream(batchCommandFile); batchFileDataInputStream = new DataInputStream(batchFileInputStream); batchFileBufferedReader = new BufferedReader(new InputStreamReader(batchFileDataInputStream)); while (batchFileBufferedReader.ready()) { String documentType = ""; String oneLine = batchFileBufferedReader.readLine(); if (oneLine.contains("<?xml version")) { documentType = oneLine; } if (oneLine.contains("<batch")) { isBatchFile = true; } if (oneLine.contains(("<ingestControl")) && oneLine.indexOf("<!") == -1) { if ((!oneLine.contains("command")) || (!oneLine.contains("type"))) { throw new FatalException("Invalid batchDescription"); } String ingestControlLine = oneLine.trim(); validCommandLine = parseCommandLine(ingestOptions, oneLine); break; } } // while } catch (NullPointerException e) { String errorMsg = "Unable to split files, Permature end of file: Corrupt:" + batchCommandFile.toString() + " ?"; throw new FatalException(errorMsg); } catch (Exception e) { String errorMsg = "Unable to split files: " + e.getMessage(); logger.fatal(errorMsg); throw new FatalException(errorMsg); } finally { try { if (batchFileBufferedReader != null) { batchFileBufferedReader.close(); } if (!isBatchFile) { throw new FatalException("ERROR: missing <batch> element!"); } if (!validCommandLine) { throw new FatalException("ERROR: missing or Invalid <batch> command line!"); } } catch (IOException e) { throw new FatalException(e.getMessage()); } } return ingestOptions; }
From source file:org.wso2.carbon.mediator.bam.StreamDefinitionBuilder.java
private void addEntityPayloadToPayloadDataList(List<Attribute> attributes) throws BamMediatorException { try {/*from ww w. j a va2s . com*/ String entryName = ""; List<StreamEntry> streamEntries = this.streamConfiguration.getEntries(); if (streamEntries != null) { for (StreamEntry streamEntry : streamEntries) { if (streamEntry.getName() != null && streamEntry.getType() != null) { if ("SOAPBody".equals(streamEntry.getName())) { entryName = "soap_body"; } else if ("SOAPHeader".equals(streamEntry.getName())) { entryName = "soap_header"; } attributes.add(new Attribute(entryName, this.resolveTypes(streamEntry.getType()))); } } } } catch (NullPointerException e) { String errorMsg = "Undefined key or type in Stream Entry. " + e.getMessage(); log.error(errorMsg, e); throw new BamMediatorException(errorMsg, e); } catch (Exception e) { String errorMsg = "Error occurred while adding the Entity Fields to Payload Data list. " + e.getMessage(); log.error(errorMsg, e); throw new BamMediatorException(errorMsg, e); } }
From source file:org.inftel.ssa.mobile.ui.fragments.ProjectEditFragment.java
public void saveProject() throws ParseException { Log.d(getClass().getSimpleName(), "Save Project"); ContentResolver cr = mActivity.getContentResolver(); ContentValues values = new ContentValues(); values.put(Projects.PROJECT_NAME, title.getText().toString()); values.put(Projects.PROJECT_SUMMARY, summary.getText().toString()); values.put(Projects.PROJECT_DESCRIPTION, description.getText().toString()); values.put(Projects.PROJECT_STARTED, secureEpochDate(started.getText().toString())); values.put(Projects.PROJECT_CLOSE, secureEpochDate(finished.getText().toString())); values.put(Projects.PROJECT_COMPANY, company.getText().toString()); values.put(Projects.PROJECT_LICENSE, license.getText().toString()); try {//from w w w .j a v a 2 s . c o m if (mState == STATE_INSERT) { values.put(Projects.SYNC_STATUS, SsaContract.STATUS_CREATED); values.put(Projects.PROJECT_OPENED, Long.toString(System.currentTimeMillis())); cr.insert(Projects.CONTENT_URI, values); } else { values.put(Projects.SYNC_STATUS, SsaContract.STATUS_DIRTY); cr.update(mContentUri, values, null, null); } } catch (NullPointerException e) { Log.e(getClass().getSimpleName(), e.getMessage()); } }
From source file:dentex.youtube.downloader.service.AutoUpgradeApkService.java
void callDownloadApk(String ver) { String apklink = getString(R.string.apk_download_sourceforge_link, ver); apkFilename = getString(R.string.apk_filename, ver); Request request = new Request(Uri.parse(apklink)); fileUri = Uri.parse(dir.toURI() + apkFilename); request.setDestinationUri(fileUri);// ww w .j av a 2 s . c om request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE); request.setTitle("YouTube Downloader v" + ver); downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); try { enqueue = downloadManager.enqueue(request); } catch (IllegalArgumentException e) { Log.e(DEBUG_TAG, "callDownloadApk: " + e.getMessage()); BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", e.getMessage(), e); } catch (NullPointerException ne) { Log.e(DEBUG_TAG, "callDownloadApk: " + ne.getMessage()); BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", ne.getMessage(), ne); } }