List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:eu.dime.userresolver.service.user.UserService.java
/** * /*from w ww .j a v a 2s.c om*/ * http://[url]/register?said=[said]&name=[name]&surname=[surname]&nickname=[nickname] * * { * version: "0.1", * result: * { name: "NAME," * surname: "SURNAME", * nickname: "NICKNAME", * said: "SAID" * } * } * */ @POST @Path("/register") @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public Response register(@FormParam("said") String said, @FormParam("name") String name, @FormParam("surname") String surname, @FormParam("nickname") String nickname) { LOG.info("Register user request: {} , {} , {} , {}", new Object[] { said, name, surname, nickname }); if (said.equals("")) return Response.ok(new ErrorResponse("Missing SAID")).status(400).build(); User user = new User(said, name, surname, nickname); String key = RandomStringUtils.randomAlphanumeric(20); user.setKey(DigestUtils.sha256Hex(key)); try { userProvider.register(user); } catch (IllegalArgumentException e) { return Response.ok(new ErrorResponse(e.getMessage())).status(400).build(); } RegisterResponse response = new RegisterResponse(); response.result = user; response.key = key; return Response.ok(response).build(); }
From source file:net.dv8tion.jda.handle.MessageReceivedHandler.java
private String handleDefaultMessage(JSONObject content) { Message message;/*from ww w . j av a 2 s . c om*/ try { message = new EntityBuilder(api).createMessage(content); } catch (IllegalArgumentException e) { EventCache.get(api).cache(EventCache.Type.CHANNEL, content.getString("channel_id"), () -> { handle(allContent); }); EventCache.LOG.debug(e.getMessage()); return null; } if (!message.isPrivate()) { TextChannel channel = api.getChannelMap().get(message.getChannelId()); if (GuildLock.get(api).isLocked(channel.getGuild().getId())) { return channel.getGuild().getId(); } api.getEventManager().handle(new GuildMessageReceivedEvent(api, responseNumber, message, channel)); } else { api.getEventManager().handle(new PrivateMessageReceivedEvent(api, responseNumber, message, api.getPmChannelMap().get(message.getChannelId()))); } //Combo event api.getEventManager().handle(new MessageReceivedEvent(api, responseNumber, message)); //searching for invites Matcher matcher = invitePattern.matcher(message.getContent()); while (matcher.find()) { InviteUtil.Invite invite = InviteUtil.resolve(matcher.group(1)); if (invite != null) { api.getEventManager().handle(new InviteReceivedEvent(api, responseNumber, message, invite)); } } return null; }
From source file:edu.cudenver.bios.chartsvc.resource.ScatterPlotResource.java
/** * Returns a full representation for a given variant. *//*from ww w.java 2 s .com*/ @Get public Representation represent(Variant variant) { queryParams = getRequest().getResourceRef().getQueryAsForm(); ChartImageRepresentation rep = null; try { // parse the chart parameters from the entity body Chart chartSpecification = ChartResourceHelper.chartFromQueryString(queryParams, false); // build a JFreeChart from the specs JFreeChart renderedChart = buildScatterPlot(chartSpecification); // write to an image representation rep = new ChartImageRepresentation(renderedChart, chartSpecification.getWidth(), chartSpecification.getHeight()); // Add file save headers if requested String saveStr = queryParams.getFirstValue(FORM_TAG_SAVE); boolean save = Boolean.parseBoolean(saveStr); if (save) { Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers"); if (responseHeaders == null) { responseHeaders = new Form(); getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders); } responseHeaders.add("Content-type", "application/force-download"); responseHeaders.add("Content-disposition", "attachment; filename=chart.jpg"); } getResponse().setEntity(rep); getResponse().setStatus(Status.SUCCESS_CREATED); } catch (IllegalArgumentException iae) { ChartLogger.getInstance().error(iae.getMessage()); try { getResponse().setEntity(new ErrorXMLRepresentation(iae.getMessage())); } catch (IOException e) { } getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST); } catch (ResourceException re) { ChartLogger.getInstance().error(re.getMessage()); try { getResponse().setEntity(new ErrorXMLRepresentation(re.getMessage())); } catch (IOException e) { } getResponse().setStatus(re.getStatus()); } return rep; }
From source file:ch.admin.suis.msghandler.servlet.MonitorServlet.java
private FilterClient handleParam(HttpServletRequest request) throws MonitorException { FilterClient filterClient = new FilterClient(); String lastProcessedParam = null; //just for exception handling try {/*from w w w . j a v a 2 s . co m*/ if (StringUtils.isNotBlank(request.getParameter(PARAM_FROM))) { lastProcessedParam = PARAM_FROM; filterClient .addFilter(new FromFilter(DateUtils.xsdDateTimeToDate(request.getParameter(PARAM_FROM)))); } if (StringUtils.isNotBlank(request.getParameter(PARAM_UNTIL))) { lastProcessedParam = PARAM_UNTIL; filterClient .addFilter(new UntilFilter(DateUtils.xsdDateTimeToDate(request.getParameter(PARAM_UNTIL)))); } if (StringUtils.isNotBlank(request.getParameter(PARAM_STATE))) { lastProcessedParam = PARAM_STATE; String sState = request.getParameter(PARAM_STATE).toUpperCase(); filterClient.addFilter(new StateFilter(LogStatus.valueOf(sState))); } if (StringUtils.isNotBlank(request.getParameter(PARAM_FILENAME))) { lastProcessedParam = PARAM_FILENAME; filterClient.addFilter(new FileNameFilter(request.getParameter(PARAM_FILENAME))); } if (StringUtils.isNotBlank(request.getParameter(PARAM_SEDEX_ID))) { lastProcessedParam = PARAM_SEDEX_ID; filterClient.addFilter(new ParticipantIdFilter(request.getParameter(PARAM_SEDEX_ID))); } if (StringUtils.isNotBlank(request.getParameter(PARAM_MESSAGE_ID))) { lastProcessedParam = PARAM_MESSAGE_ID; filterClient.addFilter(new MessageIdFilter(request.getParameter(PARAM_MESSAGE_ID))); } if (lastProcessedParam == null) { String msg = "At least one of the following parameters is required: {filename, sedexId, state, from, until, messageId}"; throw new MonitorException(msg); } return filterClient; } catch (IllegalArgumentException ex) { String msg = "Unable to parse parameter '" + lastProcessedParam + "'. Details: " + ex.getMessage(); LOG.warn(msg); throw new MonitorException(msg, ex); } }
From source file:com.plugish.woominecraft.WooMinecraft.java
@Override public void onEnable() { instance = this; this.config = (YamlConfiguration) getConfig(); // Save the default config.yml try {/*from w w w.ja v a 2 s.c o m*/ saveDefaultConfig(); } catch (IllegalArgumentException e) { getLogger().warning(e.getMessage()); } this.lang = getConfig().getString("lang"); if (lang == null) { getLogger().warning("No default l10n set, setting to english."); this.lang = "en"; } initCommands(); getLogger().info(this.getLang("log.com_init")); // Setup the scheduler scheduler = new BukkitRunner(instance); scheduler.runTaskTimerAsynchronously(instance, config.getInt("update_interval") * 20, config.getInt("update_interval") * 20); getLogger().info(this.getLang("log.enabled")); }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncInterceptorTransactionTest.java
@Test @NotTransactional//w ww . j ava 2s . c om public void shouldTestFirstThrowsException() throws Exception { beforeTx(); { EncounterType encounterType = new EncounterType(); encounterType.setName(ENCOUNTER_TYPE); encounterType.setDescription("Encounter Type Description"); String exceptionMessage = ""; try { testService.saveObjectInTransactionWithException(encounterType); } catch (IllegalArgumentException e) { exceptionMessage = e.getMessage(); } Assert.assertEquals(EXCEPTION_MESSAGE, exceptionMessage); } { VisitType visitType = new VisitType(); visitType.setName(VISIT_TYPE); visitType.setDescription("Visit Type Description"); testService.saveObjectInTransaction(visitType); } afterTx(); }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncInterceptorTransactionTest.java
@Test @NotTransactional//from w w w .jav a 2s . co m public void shouldTestSecondThrowsException() throws Exception { beforeTx(); { EncounterType encounterType = new EncounterType(); encounterType.setName(ENCOUNTER_TYPE); encounterType.setDescription("Encounter Type Description"); testService.saveObjectInTransaction(encounterType); } { VisitType visitType = new VisitType(); visitType.setName(VISIT_TYPE); visitType.setDescription("Visit Type Description"); String exceptionMessage = ""; try { testService.saveObjectInTransactionWithException(visitType); } catch (IllegalArgumentException e) { exceptionMessage = e.getMessage(); } Assert.assertEquals(EXCEPTION_MESSAGE, exceptionMessage); } afterTx(); }
From source file:com.shareplaylearn.resources.File.java
@GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @Path("/{userName}/{userId}/{filetype}/{presentationType}/{filename}") public Response getFile(@PathParam("userName") String userName, @PathParam("userId") String userId, @PathParam("filetype") String filetype, @PathParam("presentationType") String presentationTypeArg, @PathParam("filename") String filename, @HeaderParam("Authorization") String access_token, //Not entirely happy with this - Accept-Encoding would be more correct //but this is easier in the UI, in some circumstances, //and I don't want to interfere with the UA requesting compression, etc. @QueryParam("encode") String encode) { if (encode != null && encode.length() > 0) { encode = encode.toUpperCase();//from w ww . j a v a2s . c om } ItemSchema.PresentationType presentationType; try { presentationType = ItemSchema.PresentationType.fromString(presentationTypeArg); } catch (IllegalArgumentException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); } return getFileGeneric(userName, userId, filetype, presentationType, filename, access_token, encode); }
From source file:ext.services.network.TestNetworkUtils.java
/** * Test method for.//from w ww.j a v a 2 s.com * * @throws Exception the exception * {@link ext.services.network.NetworkUtils#readPostURL(java.net.HttpURLConnection, java.lang.String)} * . */ public void testReadPostURL() throws Exception { HttpURLConnection connection = NetworkUtils.getConnection(URL, null); assertNotNull(connection); connection.setDoOutput(true); // TODO: currently I do not have an URL that works via POST, therefore we // get an invalid return code try { NetworkUtils.readPostURL(connection, "post"); fail("Currently fails here"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage(), e.getMessage().contains("Invalid HTTP return code")); } connection.disconnect(); }
From source file:edu.vt.middleware.ldap.AbstractCli.java
/** * Parses command line options and invokes the proper handler to perform the * requested action, or the default action if no action is specified. * * @param args Command line arguments. *//*from w ww .jav a 2s.co m*/ public final void performAction(final String[] args) { initOptions(); try { if (args.length > 0) { final CommandLineParser parser = new GnuParser(); final CommandLine line = parser.parse(options, args); dispatch(line); } else { printExamples(); } } catch (ParseException pex) { System.err.println("Failed parsing command arguments: " + pex.getMessage()); } catch (IllegalArgumentException iaex) { String msg = "Operation failed: " + iaex.getMessage(); if (iaex.getCause() != null) { msg += " Underlying reason: " + iaex.getCause().getMessage(); } System.err.println(msg); } catch (Exception ex) { System.err.println("Operation failed:"); ex.printStackTrace(System.err); } }