List of usage examples for java.lang NullPointerException getMessage
public String getMessage()
From source file:org.openmrs.module.rheapocadapter.handler.ConnectionHandler.java
/** * @param string/*from ww w . j a v a2 s . c o m*/ * @param implementationId * the implementationId to set */ private void setImplementationId() { try { this.implementationId = Context.getAdministrationService().getImplementationId().getImplementationId(); } catch (NullPointerException e) { log.error("can't get implementationId; valur not set " + e.getMessage()); } }
From source file:org.jenkinsci.plugins.django.PythonVirtualenv.java
/** * Perform./*from w ww. j av a 2 s . c om*/ * * @param actualTasks * the actual tasks * @param projectApps * the project apps * @param settingsModule * @param requirementsFile * @param enableCoverage * the enable coverage * @return true, if successful * @throws InterruptedException * the interrupted exception * @throws IOException * Signals that an I/O exception has occurred. */ public final boolean perform(final EnumSet<Task> actualTasks, final String projectApps, String settingsModule, String requirementsFile, final boolean enableCoverage) throws InterruptedException, IOException { PrintStream logger = listener.getLogger(); logger.println("Perfroming " + actualTasks); List<PythonInstallation> pInstalls; try { pInstalls = PythonInstallationFinder.configure(); } catch (final NullPointerException e) { logger.println("No Python Installations found: " + e.getMessage()); return false; } workspace = build.getWorkspace(); if (workspace == null) { throw new IOException("No workspace found"); } final String pythonName = pInstalls.get(0).getName(); final ArrayList<String> commandList = new ArrayList<String>(); /* First upgrade pip and friends */ logger.println("Upgrade pip first."); commandList.add(PIP_INSTALL + PIP_UPGRADE + "pip"); /* DjangoJenkins Requirements (can be overridden by project ones) */ logger.println("Installing Django Requirements"); commandList.add(installDjangoJenkinsRequirements(actualTasks, enableCoverage)); /* Project Requirements */ logger.println("Installing Project Requirements"); commandList.add(installProjectRequirements(requirementsFile)); logger.println("Building jenkins package/module"); commandList.add(createBuildPackage(actualTasks, projectApps, settingsModule)); logger.println("Adding jenkins tasks"); String jenkinsCli = "$PYTHON_EXE manage.py jenkins"; if (enableCoverage) { jenkinsCli += " " + ENABLE_COVERAGE; } commandList.add(jenkinsCli + "\n"); final String command = StringUtils.join(commandList, "\n"); logger.println("Command:\n" + command); logger.println("Final Command: "); logger.println(command); logger.println("Creating VirtualnevBuilder"); final VirtualenvBuilder venv = new VirtualenvBuilder(pythonName, "django-jenkins", false, false, "Shell", command.toString(), false); logger.println("Performing in VirtualenvBuilder"); return venv.perform(build, launcher, listener); }
From source file:edu.vt.vbi.patric.dao.DBSummary.java
/** * Retrieves RNA detail info. This query on app.dnafeature and dots.nafeaturecomment tables. * /* w ww . ja va 2s .co m*/ * @param id na_feature_id * @return RNA info (na_feature_id, gene, label, anticodon, product, comment_string) */ public ResultType getRNAInfo(String id) { String sql = "select nf.na_feature_id, nf.gene, nf.label, nf.anticodon, nf.product, nfc.comment_string " + " from app.dnafeature nf, dots.nafeaturecomment nfc where nf.na_feature_id = ? " + " and nf.na_feature_id = nfc.na_feature_id(+)"; Session session = factory.getCurrentSession(); session.beginTransaction(); SQLQuery q = session.createSQLQuery(sql); q.setString(0, id); ResultType result = new ResultType(); for (Object aRset : q.list()) { Object[] obj = (Object[]) aRset; result.put("na_feature_id", obj[0]); result.put("gene", obj[1]); result.put("label", obj[2]); result.put("anticodon", obj[3]); result.put("product", obj[4]); try { SerializableClob clobComment = (SerializableClob) obj[5]; String strComment = IOUtils.toString(clobComment.getAsciiStream(), "UTF-8"); result.put("comment_string", strComment); } catch (NullPointerException ex) { // this can be null } catch (Exception ex) { LOGGER.error("Problem in retrieving comments for RNA: {}", ex.getMessage(), ex); } } return result; }
From source file:com.yahoo.pulsar.client.impl.ConsumerBase.java
@Override public void acknowledge(Message message) throws PulsarClientException { try {/* w ww . j a v a2 s. com*/ acknowledge(message.getMessageId()); } catch (NullPointerException npe) { throw new PulsarClientException.InvalidMessageException(npe.getMessage()); } }
From source file:com.yahoo.pulsar.client.impl.ConsumerBase.java
@Override public void acknowledgeCumulative(Message message) throws PulsarClientException { try {// www .j av a 2 s .c om acknowledgeCumulative(message.getMessageId()); } catch (NullPointerException npe) { throw new PulsarClientException.InvalidMessageException(npe.getMessage()); } }
From source file:edu.harvard.mcz.imagecapture.TemplatePickerDialog.java
protected void init(ICImage image) { setBounds(100, 100, 450, 300);//from w w w. jav a 2 s . co m StringBuffer title = new StringBuffer(); title.append("Change Template"); if (image != null) { title.append(" for ").append(image.getFilename()); } this.setTitle(title.toString()); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { lblTemplate = new JLabel("Template"); lblTemplate.setHorizontalAlignment(SwingConstants.CENTER); contentPanel.add(lblTemplate, BorderLayout.NORTH); } { comboBoxTemplatePicker = new JComboBox<String>(); comboBoxTemplatePicker.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub PositionTemplate defaultTemplate; try { defaultTemplate = new PositionTemplate((String) comboBoxTemplatePicker.getSelectedItem()); File fileToCheck = new File(ImageCaptureProperties .assemblePathWithBase(imageToTemplate.getPath(), imageToTemplate.getFilename())); BufferedImage imagefile = ImageIO.read(fileToCheck); int x = defaultTemplate.getBarcodeULPosition().width; int y = defaultTemplate.getBarcodeULPosition().height; int w = defaultTemplate.getBarcodeSize().width; int h = defaultTemplate.getBarcodeSize().height; setBarcodeImage(imagefile.getSubimage(x, y, w, h)); } catch (NullPointerException e1) { log.error(e1.getMessage()); } catch (NoSuchTemplateException e1) { log.error(e1.getMessage()); } catch (IOException e1) { log.error(e1.getMessage()); } } }); contentPanel.add(comboBoxTemplatePicker, BorderLayout.SOUTH); } { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.CENTER); panel.setLayout(new BorderLayout(0, 0)); { lblFileName = new JLabel("FileName"); panel.add(lblFileName, BorderLayout.NORTH); } { labelBarcodeImage = new JLabel("Catalog Number Barcode"); labelBarcodeImage.setIcon(new ImageIcon(TemplatePickerDialog.class .getResource("/edu/harvard/mcz/imagecapture/resources/gnome-mime-image.png"))); panel.add(labelBarcodeImage, BorderLayout.CENTER); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub ICImageLifeCycle ils = new ICImageLifeCycle(); try { String newTemplateID = (String) comboBoxTemplatePicker.getSelectedItem(); if (newTemplateID != null) { imageToTemplate.setTemplateId(newTemplateID); ils.attachDirty(imageToTemplate); setVisible(false); } } catch (SaveFailedException e1) { log.error(e1.getMessage(), e1); } } }); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPane.add(cancelButton); } } if (image != null) { try { boolean result = setupForImage(image); } catch (UnreadableFileException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:org.elasticsearch.client.sniff.ElasticsearchNodesSnifferTests.java
public void testConstructorValidation() throws IOException { try {/*from www. j ava 2s. c om*/ new ElasticsearchNodesSniffer(null, 1, ElasticsearchNodesSniffer.Scheme.HTTP); fail("should have failed"); } catch (NullPointerException e) { assertEquals("restClient cannot be null", e.getMessage()); } HttpHost httpHost = new HttpHost(httpServer.getAddress().getHostString(), httpServer.getAddress().getPort()); try (RestClient restClient = RestClient.builder(httpHost).build()) { try { new ElasticsearchNodesSniffer(restClient, 1, null); fail("should have failed"); } catch (NullPointerException e) { assertEquals(e.getMessage(), "scheme cannot be null"); } try { new ElasticsearchNodesSniffer(restClient, RandomNumbers.randomIntBetween(getRandom(), Integer.MIN_VALUE, 0), ElasticsearchNodesSniffer.Scheme.HTTP); fail("should have failed"); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "sniffRequestTimeoutMillis must be greater than 0"); } } }
From source file:com.normalexception.app.rx8club.html.VBForumFactory.java
/** * Get the page context from from a supplied forum address * @param src The source activity//ww w .j a v a 2 s . co m * @param lf The login factory object * @param addr The address to grab information from * @return The output text for the page * @throws ClientProtocolException * @throws IOException */ public String getForumPage(Activity src, LoginFactory lf, String addr) throws ClientProtocolException, IOException { String output = null; try { CloseableHttpClient client = null; // Grab the login client Log.d(TAG, "Grabbing Login Client"); client = lf.getClient(); // If client isn't null, continue if (client != null && (addr != null && !addr.equals(""))) { HttpGet httpget = null; Log.d(TAG, "Resolving URL"); addr = Utils.resolveUrl(addr); try { Log.d(TAG, "Executing HTTP Get on: " + addr); httpget = ClientUtils.getHttpGet(addr); output = EntityUtils.toString(client.execute(httpget, lf.getHttpContext()).getEntity(), "ISO-8859-1"); // Automatically released in new versions // of httpclient //httpget.releaseConnection(); if (output == null || output.equals("") || output.contains("You are not logged in")) { Log.w(TAG, "Error Parsing Output!"); Log.w(TAG, output); FragmentUtils.returnToLoginPage(src, FragmentUtils.LogoutReason.ERROR); } } catch (NullPointerException e) { notifyError(src, "Error Opening Page. This Has Been Logged", e); } catch (IllegalStateException e) { Log.e(TAG, e.getMessage(), e); } } else { notifyError(src, "Error With Credentials", null); } } catch (Exception e) { notifyError(src, "No Internet Connection...", e); FragmentUtils.returnToLoginPage(src, FragmentUtils.LogoutReason.ERROR); } if (output == null || output.length() == 0) { notifyError(src, "No Internet Connection...", null); FragmentUtils.returnToLoginPage(src, FragmentUtils.LogoutReason.ERROR); } return output; }
From source file:org.restcomm.connect.http.ExtensionsConfigurationEndpoint.java
protected Response updateConfiguration(String extensionSid, MultivaluedMap<String, String> data, MediaType responseType) {//from w w w . ja va2 s .co m if (!isSuperAdmin()) { throw new InsufficientPermission(); } if (!Sid.pattern.matcher(extensionSid).matches()) { return status(BAD_REQUEST).build(); } ExtensionConfiguration extensionConfiguration = extensionsConfigurationDao .getConfigurationBySid(new Sid(extensionSid)); if (extensionConfiguration == null) { return status(NOT_FOUND).build(); } ExtensionConfiguration updatedExtensionConfiguration = null; Sid accountSid = null; String accountSidQuery = data.getFirst("AccountSid"); if (accountSidQuery != null && !accountSidQuery.isEmpty()) { accountSid = new Sid(accountSidQuery); } try { updatedExtensionConfiguration = prepareUpdatedConfiguration(extensionConfiguration, data, responseType); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } try { if (accountSid == null) { extensionsConfigurationDao.updateConfiguration(updatedExtensionConfiguration); } else { extensionsConfigurationDao.updateAccountExtensionConfiguration(updatedExtensionConfiguration, accountSid); } } catch (ConfigurationException exception) { return status(NOT_ACCEPTABLE).entity(exception.getMessage()).build(); } if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(updatedExtensionConfiguration), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(updatedExtensionConfiguration); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }
From source file:org.restcomm.sbc.rest.AccountsEndpoint.java
protected Response putAccount(final MultivaluedMap<String, String> data, final MediaType responseType) { //First check if the account has the required permissions in general, this way we can fail fast and avoid expensive DAO operations checkPermission("RestComm:Create:Accounts"); // what if effectiveAccount is null ?? - no need to check since we checkAuthenticatedAccount() in AccountsEndoint.init() final Sid sid = userIdentityContext.getEffectiveAccount().getSid(); Account account = null;//from ww w .j a v a 2 s . c o m try { account = createFrom(sid, data); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } // If Account already exists don't add it again /* Account creation rules: - either be Administrator or have the following permission: RestComm:Create:Accounts - only Administrators can choose a role for newly created accounts. Normal users will create accounts with the same role as their own. */ if (accountsDao.getAccount(account.getSid()) == null && !account.getEmailAddress().equalsIgnoreCase("administrator@company.com")) { final Account parent = accountsDao.getAccount(sid); if (parent.getStatus().equals(Account.Status.ACTIVE) && isSecuredByPermission("RestComm:Create:Accounts")) { if (!hasAccountRole(getAdministratorRole()) || !data.containsKey("Role")) { account = account.setRole(parent.getRole()); } accountsDao.addAccount(account); // Create default SIP client data MultivaluedMap<String, String> clientData = new MultivaluedMapImpl(); String username = data.getFirst("EmailAddress").split("@")[0]; clientData.add("Login", username); clientData.add("Password", data.getFirst("Password")); clientData.add("FriendlyName", account.getFriendlyName()); clientData.add("AccountSid", account.getSid().toString()); } else { throw new InsufficientPermission(); } } else { return status(CONFLICT).entity("The email address used for the new account is already in use.").build(); } if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(account), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(account); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }