List of usage examples for java.lang NullPointerException getMessage
public String getMessage()
From source file:org.venice.piazza.serviceregistry.controller.messaging.handlers.HandlerLoggingTest.java
@Test @Ignore//from w ww . j av a 2s.c o m public void TestListServiceHandlerFailLogging() { ListServicesJob lsj = new ListServicesJob(); ArrayList<Service> services = new ArrayList<Service>(); services.add(service); NullPointerException ex = new NullPointerException("Test Error"); when(mockMongo.list()).thenThrow(ex); lsHandler.handle(lsj); assertTrue(logString.contains(ex.getMessage())); }
From source file:com.coloreight.plugin.socialAuth.SocialAuth.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); fbCallbackManager.onActivityResult(requestCode, resultCode, intent); if (requestCode == SocialAuth.TWITTER_OAUTH_REQUEST) { if (resultCode == Activity.RESULT_OK) { Log.v(TAG, "On activity result with authtoken: " + intent.getExtras().keySet()); for (String key : intent.getExtras().keySet()) { Object value = intent.getExtras().get(key); try { String valueStr = value.toString(); Log.v("AUTH", String.format("%s %s (%s)", key, valueStr, value.getClass().getName())); } catch (NullPointerException e) { Log.v(TAG, e.getMessage()); }/*from w w w .ja v a 2 s. co m*/ } this.getTwitterSystemAccount(this.requestedTwitterAccountName, callbackContext); } else if (resultCode == Activity.RESULT_CANCELED) { callbackContext.error("Twitter auth activity canceled"); } } }
From source file:org.energy_home.jemma.javagal.rest.resources.ServicesResource.java
@Get public void processGet() { String addrString = (String) getRequest().getAttributes().get("addr"); Address address = new Address(); if (addrString.length() > 4) { BigInteger addressBigInteger = BigInteger.valueOf(Long.parseLong(addrString, 16)); address.setIeeeAddress(addressBigInteger); } else {/* www . j av a2 s. c o m*/ Integer addressInteger = Integer.parseInt(addrString, 16); address.setNetworkAddress(addressInteger); } Parameter timeoutParam = getRequest().getResourceRef().getQueryAsForm() .getFirst(Resources.URI_PARAM_TIMEOUT); if (timeoutParam != null) { timeoutString = timeoutParam.getValue().trim(); try { timeout = Long.decode(Resources.HEX_PREFIX + timeoutString); // if (timeout < 0 || timeout > 0xffff) { if (!Util.isUnsigned32(timeout)) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage("Error: optional '" + ResourcePathURIs.TIMEOUT_PARAM + "' parameter's value invalid. You provided: " + timeoutString); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } } catch (NumberFormatException nfe) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage("Error: optional '" + ResourcePathURIs.TIMEOUT_PARAM + "' parameter's value invalid. You provided: " + timeoutString); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } } // Urilistener parameter String urilistener = null; Parameter urilistenerParam = getRequest().getResourceRef().getQueryAsForm() .getFirst(Resources.URI_PARAM_URILISTENER); // Urilistener is mandatory if (urilistenerParam != null) { // TODO Marco why getSecond() and not getValue()? // urilistener = urilistenerParam.getSecond(); urilistener = urilistenerParam.getValue(); } try { if (urilistener == null) { // Synch StartServiceDiscovery proxyGalInterface = getRestManager().getClientObjectKey(-1, getClientInfo().getAddress()) .getGatewayInterface(); NodeServices node = proxyGalInterface.startServiceDiscoverySync(timeout, address); Info.Detail detail = new Info.Detail(); detail.setNodeServices(node); Info infoToReturn = new Info(); Status status = new Status(); status.setCode((short) GatewayConstants.SUCCESS); infoToReturn.setStatus(status); infoToReturn.setDetail(detail); getResponse().setEntity(Util.marshal(infoToReturn), MediaType.TEXT_XML); return; } else { // Asynch ClientResources rcmal = getRestManager() .getClientObjectKey(Util.getPortFromUriListener(urilistener), getClientInfo().getAddress()); proxyGalInterface = rcmal.getGatewayInterface(); if (!urilistener.equals("")) { rcmal.getClientEventListener().setNodeServicesDestination(urilistener); } proxyGalInterface.startServiceDiscovery(timeout, address); Info.Detail detail = new Info.Detail(); Info infoToReturn = new Info(); Status status = new Status(); status.setCode((short) GatewayConstants.SUCCESS); infoToReturn.setStatus(status); infoToReturn.setRequestIdentifier(Util.getRequestIdentifier()); infoToReturn.setDetail(detail); getResponse().setEntity(Util.marshal(infoToReturn), MediaType.TEXT_XML); return; } } catch (NullPointerException npe) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage(npe.getMessage()); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } catch (Exception e) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage(e.getMessage()); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } }
From source file:gov.nih.nci.caadapter.ws.AddNewScenario.java
/** ********************************************************** * doPost()//from ww w.j a va 2 s . c o m ************************************************************ */ public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { /* disable security for caAdatper 4.3 release 03-31-2009 HttpSession session = req.getSession(false); if(session==null) { res.sendRedirect("/caAdapterWS/login.do"); return; } String user = (String) session.getAttribute("userid"); System.out.println(user); AbstractSecurityDAO abstractDao= DAOFactory.getDAO(); SecurityAccessIF getSecurityAccess = abstractDao.getSecurityAccess(); Permissions perm = getSecurityAccess.getUserObjectPermssions(user, 1); System.out.println(perm); if (!perm.getCreate()){ System.out.println("No create Permission for user" + user); res.sendRedirect("/caAdapterWS/permissionmsg.do"); return; } */ String name = "EMPTY"; // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Parse the request List /* FileItem */ items = upload.parseRequest(req); // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { if (item.getFieldName().equals("MSName")) { MSName = item.getString(); path = System.getProperty("gov.nih.nci.caadapter.path"); if (path == null) path = ScenarioUtil.SCENARIO_HOME; File scnHome = new File(path); if (!scnHome.exists()) scnHome.mkdir(); path = path + "/"; System.out.println(path); boolean exists = (new File(path + MSName)).exists(); if (exists) { System.out.println("Scenario exists, overwriting ... ..."); String errMsg = "Scenario exists, not able to save:" + MSName; req.setAttribute("rtnMessage", errMsg); res.sendRedirect("/caAdapterWS/errormsg.do"); return; } else { boolean success = (new File(path + MSName)).mkdir(); if (!success) { System.out.println("New scenario, Creating ... ..."); } } } } else { System.out.println(item.getFieldName()); name = item.getFieldName(); String filePath = item.getName(); String fileName = extractOriginalFileName(filePath); System.out.println("AddNewScenario.doPost()..original file Name:" + fileName); if (fileName == null || fileName.equals("")) continue; String uploadedFilePath = path + MSName + "/" + fileName; System.out.println("AddNewScenario.doPost()...write data to file:" + uploadedFilePath); File uploadedFile = new File(uploadedFilePath); if (name.equals("mappingFileName")) { String uploadedMapBak = uploadedFilePath + ".bak"; //write bak of Mapping file item.write(new File(uploadedMapBak)); updateMapping(uploadedMapBak); } else item.write(uploadedFile); } } ScenarioUtil.addNewScenarioRegistration(MSName); res.sendRedirect("/caAdapterWS/success.do"); } catch (NullPointerException ne) { System.out.println("Error in doPost: " + ne); req.setAttribute("rtnMessage", ne.getMessage()); res.sendRedirect("/caAdapterWS/errormsg.do"); } catch (Exception e) { System.out.println("Error in doPost: " + e); req.setAttribute("rtnMessage", e.getMessage()); res.sendRedirect("/caAdapterWS/error.do"); } }
From source file:org.apache.hadoop.hbase.mapred.TestLegacyTableMapReduce.java
private void verify(String tableName) throws IOException { HTable table = new HTable(conf, tableName); boolean verified = false; long pause = conf.getLong("hbase.client.pause", 5 * 1000); int numRetries = conf.getInt("hbase.client.retries.number", 5); for (int i = 0; i < numRetries; i++) { try {//ww w . j a va2s. c o m LOG.info("Verification attempt #" + i); verifyAttempt(table); verified = true; break; } catch (NullPointerException e) { // If here, a cell was empty. Presume its because updates came in // after the scanner had been opened. Wait a while and retry. LOG.debug("Verification attempt failed: " + e.getMessage()); } try { Thread.sleep(pause); } catch (InterruptedException e) { // continue } } assertTrue(verified); }
From source file:org.pentaho.hadoop.shim.common.DistributedCacheUtilImplTest.java
@Test public void extractToTemp_missing_archive() throws Exception { DistributedCacheUtilImpl ch = new DistributedCacheUtilImpl(TEST_CONFIG); try {/* w w w . j a v a2 s .c om*/ ch.extractToTemp(null); fail("Expected exception"); } catch (NullPointerException ex) { assertEquals("archive is required", ex.getMessage()); } }
From source file:com.scto.filerenamer.MainActivity.java
/** Called when the activity is first created. */ @Override//from w w w . j av a 2s. com public void onCreate(Bundle savedInstanceState) { try { mSharedPreferences = Prefs.getSharedPreferences(this); } catch (NullPointerException e) { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "mSharedPreferences == NullPointerException :" + e.getMessage()); } } mSharedPreferences.registerOnSharedPreferenceChangeListener(this); if (Prefs.getThemeType(this) == false) { mThemeId = R.style.AppTheme_Light; setTheme(mThemeId); } else { mThemeId = R.style.AppTheme_Dark; setTheme(mThemeId); } //Eula.showDisclaimer( this ); Eula.showEula(this, getApplicationContext()); mActionBar = getActionBar(); if (mActionBar != null) { mActionBar.setDisplayHomeAsUpEnabled(false); mActionBar.setDisplayShowHomeEnabled(true); mActionBar.setDisplayShowTitleEnabled(true); } else { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "mActionBar == null"); } } Bundle extras = getIntent().getExtras(); if (extras != null) { this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name)); } else { this.setTitle(" :: " + getString(R.string.app_name)); } super.onCreate(savedInstanceState); setContentView(R.layout.main); tvDisplay = (TextView) findViewById(R.id.tvDisplay); bRename = (Button) findViewById(R.id.bRename); bSettings = (Button) findViewById(R.id.bSettings); bHelp = (Button) findViewById(R.id.bHelp); bExit = (Button) findViewById(R.id.bExit); bRename.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent openAndroidFileBrowser = new Intent("com.scto.filerenamer.ANDROIDFILEBROWSER"); openAndroidFileBrowser.putExtra("what", "renamer"); openAndroidFileBrowser.putExtra("theme", mThemeId); startActivity(openAndroidFileBrowser); } }); bSettings.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent openPreferencesActivity = new Intent("com.scto.filerenamer.PREFERENCESACTIVITY"); startActivity(openPreferencesActivity); } }); bHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); HelpDialog helpDialog = new HelpDialog(); helpDialog.show(fm, "dlg_help"); } }); bExit.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); ExitDialog exitDialog = new ExitDialog(); exitDialog.show(fm, "dlg_exit"); } }); /* ChangeLog cl = new ChangeLog( this ); if( cl.firstRun() ) { cl.getLogDialog().show(); } */ init(); }
From source file:org.apache.hadoop.hbase.mapreduce.TestMultithreadedTableMapper.java
private void verify(String tableName) throws IOException { HTable table = new HTable(new Configuration(UTIL.getConfiguration()), tableName); boolean verified = false; long pause = UTIL.getConfiguration().getLong("hbase.client.pause", 5 * 1000); int numRetries = UTIL.getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 5); for (int i = 0; i < numRetries; i++) { try {// ww w .j a v a 2 s . c om LOG.info("Verification attempt #" + i); verifyAttempt(table); verified = true; break; } catch (NullPointerException e) { // If here, a cell was empty. Presume its because updates came in // after the scanner had been opened. Wait a while and retry. LOG.debug("Verification attempt failed: " + e.getMessage()); } try { Thread.sleep(pause); } catch (InterruptedException e) { // continue } } assertTrue(verified); table.close(); }
From source file:org.mobicents.servlet.restcomm.http.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;//w w w . ja va2 s. c om 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()); Client client = clientDao.getClient(clientData.getFirst("Login")); if (client == null) { client = createClientFrom(account.getSid(), clientData); clientDao.addClient(client); } } 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; } }
From source file:com.idevity.card.read.ShowCert.java
/** * Method onCreateView.//w w w.ja v a2 s . co m * * @param inflater * LayoutInflater * @param container * ViewGroup * @param savedInstanceState * Bundle * @return View */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Globals g = Globals.getInstance(); byte[] _data = g.getCard(); CardData80073 carddata = new CardData80073(_data); X509Certificate cardAuth = null; String issuer = new String(); String subject = new String(); String validfrom = new String(); String validto = new String(); try { PIVCertificate pca = null; PIVDataTempl dataTempl = carddata.getCardAuthCertificate(); if (dataTempl != null) { byte[] data = dataTempl.getData(); if (data == null) { data = dataTempl.getEncoded(); } pca = new PIVCertificate(data); } cardAuth = pca.getCertificate(); } catch (NullPointerException e) { if (debug) { Log.d(TAG, "Error: No Card Authentication Certificate Received"); } } catch (Throwable e) { Log.e(TAG, "Error: " + e.getMessage()); } if (cardAuth != null) { /* * The default implementation does not decode the * DN in a very human friendly form. The following * Map and Format variables will help to better decode * the X500Principal object to a String value. */ HashMap<String, String> oidMap = new HashMap<String, String>(); oidMap.put("2.5.4.5", "SERIALNUMBER"); String dnFormat = "RFC1779"; /* * Get the values from the certificate */ issuer = cardAuth.getIssuerX500Principal().getName(dnFormat, oidMap); subject = cardAuth.getSubjectX500Principal().getName(dnFormat, oidMap); validfrom = cardAuth.getNotBefore().toString(); validto = cardAuth.getNotAfter().toString(); /* * Populate the UI */ View certLayout = inflater.inflate(R.layout.activity_show_cert, container, false); ImageView valPeriodIndicator = (ImageView) certLayout.findViewById(R.id.cert_ind_vp); ImageView popIndicator = (ImageView) certLayout.findViewById(R.id.cert_ind_pop); TextView valPeriodLabel = (TextView) certLayout.findViewById(R.id.cert_vp_label); TextView popLabel = (TextView) certLayout.findViewById(R.id.cert_pop_label); TextView vfText = (TextView) certLayout.findViewById(R.id.cert_nb_label); TextView vtText = (TextView) certLayout.findViewById(R.id.cert_na_label); /* * Assume the cert is good unless an exception * is thrown below. */ valPeriodIndicator.setImageResource(R.drawable.cert_good); /* * Note to self. I am not thrilled how Java almost forces you * to assume a certificate if valid unless an exception is thrown! */ try { cardAuth.checkValidity(); } catch (CertificateNotYetValidException e) { valPeriodIndicator.setImageResource(R.drawable.cert_bad); valPeriodLabel.setTextColor(getResources().getColor(R.color.idredmain)); vfText.setTextColor(getResources().getColor(R.color.idredmain)); if (debug) { Log.d(TAG, "Error: Authentication Certificate Not Valid Yet!"); } } catch (CertificateExpiredException e) { valPeriodIndicator.setImageResource(R.drawable.cert_bad); valPeriodLabel.setTextColor(getResources().getColor(R.color.idredmain)); vtText.setTextColor(getResources().getColor(R.color.idredmain)); if (debug) { Log.d(TAG, "Error: Card Authentication Certificate Expired!"); } } CAKChallenge popVerify = new CAKChallenge(cardAuth, carddata.getCAKPoPNonce(), carddata.getCAKPoPSig()); try { if (popVerify.validatePOP()) { popIndicator.setImageResource(R.drawable.cert_good); if (debug) { Log.d(TAG, "Proof of Possession Verified!"); } } else { popIndicator.setImageResource(R.drawable.cert_bad); popLabel.setTextColor(getResources().getColor(R.color.idredmain)); if (debug) { Log.d(TAG, "Proof of Possession Failed!"); } } } catch (SignatureException e) { popIndicator.setImageResource(R.drawable.cert_bad); popLabel.setTextColor(getResources().getColor(R.color.idredmain)); if (debug) { Log.d(TAG, "Problem with Proof of Possession: " + e.getMessage()); } } TextView editCertSubject = (TextView) certLayout.findViewById(R.id.cert_sub_dn); editCertSubject.setText(subject); TextView editValidFrom = (TextView) certLayout.findViewById(R.id.cert_nb_date); editValidFrom.setText(validfrom); TextView editValidTo = (TextView) certLayout.findViewById(R.id.cert_na_date); editValidTo.setText(validto); TextView editIssuer = (TextView) certLayout.findViewById(R.id.cert_iss_dn); editIssuer.setText(issuer); return certLayout; } else { View certLayout = inflater.inflate(R.layout.activity_no_cert, container, false); return certLayout; } }