List of usage examples for java.lang NullPointerException getMessage
public String getMessage()
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendAddAdventOfCodeProjectResult() { try {/* w w w. j a v a 2s . co m*/ String inputFileContent = request.getParameter("inputFileContent"); String name = request.getParameter("name"); String publicIds = MySqlConnector.getInstance().addAdventOfCodeProject(sessionInfo.getUserInfo(), name, inputFileContent); writeResponse(publicIds, HttpServletResponse.SC_OK); } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_FORBIDDEN); } }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendRenameFileResult() { try {/* www. j ava 2 s. c o m*/ String publicId = request.getParameter("publicId"); String newName = request.getParameter("newName"); newName = newName.endsWith(".kt") ? newName : newName + ".kt"; MySqlConnector.getInstance().renameFile(sessionInfo.getUserInfo(), publicId, newName); writeResponse("ok", HttpServletResponse.SC_OK); } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_FORBIDDEN); } }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendFileExistenceResult() { try {/*from w ww . j ava2s . c om*/ ObjectNode response = new ObjectNode(JsonNodeFactory.instance); if (MySqlConnector.getInstance().getFile(request.getParameter("publicId")) != null) { response.put("exists", true); } else { response.put("exists", false); } writeResponse(response.toString(), HttpServletResponse.SC_OK); } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); } }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendLoadProjectNameResult() { try {//www. j ava2 s . c om String project_id = request.getParameter("project_id"); String response = MySqlConnector.getInstance().getProjectNameById(project_id); if (response != null) { writeResponse(response, HttpServletResponse.SC_OK); } else { writeResponse("", HttpServletResponse.SC_NOT_FOUND); } } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); } }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendDeleteFileResult() { try {/*from w w w.ja v a 2s . co m*/ sessionInfo.setType(SessionInfo.TypeOfRequest.DELETE_FILE); boolean modifiable = Boolean.parseBoolean(request.getParameter("modifiable")); if (modifiable) { String publicId = request.getParameter("fileId"); MySqlConnector.getInstance().deleteFile(sessionInfo.getUserInfo(), publicId); } else { String fileName = request.getParameter("fileName"); String projectId = request.getParameter("projectId"); MySqlConnector.getInstance().deleteUnmodifiableFile(sessionInfo.getUserInfo(), fileName, projectId); } writeResponse(HttpServletResponse.SC_OK); } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_FORBIDDEN); } }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendLoadProjectResult() { try {//from w w w. j a v a 2 s.com String id = request.getParameter("publicId"); Project result = MySqlConnector.getInstance().getProjectContent(id); if (result != null) { if (!KotlinVersionsManager.INSTANCE.getKotlinVersions().contains(result.getCompilerVersion())) { result.setCompilerVersion(KotlinVersionsManager.INSTANCE.getLatestStableVersion()); } writeResponse(objectMapper.writeValueAsString(result), HttpServletResponse.SC_OK); } else { writeResponse("", HttpServletResponse.SC_NOT_FOUND); } } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); } catch (IOException e) { writeResponse("Can't serialize project", HttpServletResponse.SC_BAD_REQUEST); } }
From source file:org.apache.gora.dynamodb.store.DynamoDBNativeStore.java
/** * Puts an object identified by a key/*ww w . jav a 2 s . co m*/ * * @param key * @param obj */ @Override public void put(K key, T obj) { try { Object hashKey = getHashKey(key, obj); Object rangeKey = getRangeKey(key, obj); if (hashKey != null) { DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBStoreHandler.getDynamoDbClient()); if (rangeKey != null) { mapper.load(persistentClass, hashKey, rangeKey); } else { mapper.load(persistentClass, hashKey); } mapper.save(obj); } else throw new GoraException("No HashKey found in Key nor in Object."); } catch (NullPointerException npe) { LOG.error("Error while putting an item. " + npe.toString()); throw new NullArgumentException(npe.getMessage()); } catch (Exception e) { LOG.error("Error while putting an item. " + obj.toString()); throw new RuntimeException(e); } }
From source file:org.wso2.carbon.sequences.ui.client.SequenceAdminClient.java
public void addSequence(SequenceMediator sequence) throws SequenceEditorException { OMElement sequenceElem = null;//from ww w. ja v a 2s.co m try { sequenceElem = sequence.serialize(null); sequenceAdminStub.addSequence(sequenceElem); } catch (NullPointerException e) { handleException("Error in adding the sequence with the configuration '" + sequenceElem + "' : Please make" + " sure to click the update button after configuring a mediator.", e); } catch (Exception e) { if (e.getMessage().toString().toLowerCase().contains("this name already exists".toLowerCase())) { //Error Related to name already exits throw new SequenceEditorException(e.getMessage(), e); } else { handleException("Error in adding the sequence with the configuration '" + sequenceElem + "'. " + e.getMessage(), e); } } }
From source file:dentex.youtube.downloader.service.DownloadsService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { copyEnabled = intent.getBooleanExtra("COPY", false); Utils.logger("d", "Copy to extSdcard: " + copyEnabled, DEBUG_TAG); audio = intent.getStringExtra("AUDIO"); Utils.logger("d", "Audio extraction: " + audio, DEBUG_TAG); removeVideo = settings.getBoolean("remove_video", false); try {//from ww w .j a va 2s .c o m if (audio.equals("none")) removeVideo = false; } catch (NullPointerException ne) { removeVideo = false; Log.e(DEBUG_TAG, "DownloadsService: " + ne.getMessage()); BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> DownloadsService: ", ne.getMessage(), ne); } Utils.logger("d", "Video removal: " + removeVideo, DEBUG_TAG); super.onStartCommand(intent, flags, startId); return START_NOT_STICKY; }
From source file:org.restcomm.connect.http.IncomingPhoneNumbersEndpoint.java
protected Response putIncomingPhoneNumber(final String accountSid, final MultivaluedMap<String, String> data, PhoneNumberType phoneNumberType, final MediaType responseType) { secure(accountsDao.getAccount(accountSid), "RestComm:Create:IncomingPhoneNumbers"); try {//from w ww . j ava2s . c o m validate(data); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } String number = data.getFirst("PhoneNumber"); String isSIP = data.getFirst("isSIP"); // cater to SIP numbers if (isSIP == null) { try { number = e164(number); } catch (NumberParseException e) { } } IncomingPhoneNumber incomingPhoneNumber = dao.getIncomingPhoneNumber(number); if (incomingPhoneNumber == null) { incomingPhoneNumber = createFrom(new Sid(accountSid), data); phoneNumberParameters.setPhoneNumberType(phoneNumberType); org.restcomm.connect.provisioning.number.api.PhoneNumber phoneNumber = convertIncomingPhoneNumbertoPhoneNumber( incomingPhoneNumber); boolean hasSuceeded = false; if (phoneNumberProvisioningManager != null && isSIP == null) { ApiRequest apiRequest = new ApiRequest(accountSid, data, ApiRequest.Type.INCOMINGPHONENUMBER); //Before proceed to buy the DID, check with the extensions if the purchase is allowed or not if (executePreApiAction(apiRequest)) { hasSuceeded = phoneNumberProvisioningManager.buyNumber(phoneNumber, phoneNumberParameters); } else { //Extensions didn't allowed this API action hasSuceeded = false; if (logger.isInfoEnabled()) { logger.info("DID purchase is now allowed for this account"); } } executePostApiAction(apiRequest); //If Extension blocked the request, return the proper error response if (!hasSuceeded) { String msg = "DID purchase is now allowed for this account"; String error = "DID_QUOTA_EXCEEDED"; return status(FORBIDDEN).entity(buildErrorResponseBody(msg, error, responseType)).build(); } } else if (isSIP != null) { hasSuceeded = true; } if (hasSuceeded) { if (phoneNumber.getFriendlyName() != null) { incomingPhoneNumber.setFriendlyName(phoneNumber.getFriendlyName()); } if (phoneNumber.getPhoneNumber() != null) { incomingPhoneNumber.setPhoneNumber(phoneNumber.getPhoneNumber()); } dao.addIncomingPhoneNumber(incomingPhoneNumber); if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(incomingPhoneNumber), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(incomingPhoneNumber); return ok(xstream.toXML(response), APPLICATION_XML).build(); } } } return status(BAD_REQUEST).entity("21452").build(); }