List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:ch.cyberduck.core.irods.IRODSSession.java
@Override protected IRODSFileSystemAO connect(final HostKeyCallback key) throws BackgroundException { try {//from w ww . j av a2 s .co m final IRODSFileSystem fs = this.configure(IRODSFileSystem.instance()); final IRODSAccessObjectFactory factory = fs.getIRODSAccessObjectFactory(); final String region = this.getRegion(); final String resource = this.getResource(); final Credentials credentials = host.getCredentials(); try { return factory.getIRODSFileSystemAO(new URIEncodingIRODSAccount(credentials.getUsername(), credentials.getPassword(), new IRODSHomeFinderService(IRODSSession.this).find().getAbsolute(), region, resource)); } catch (IllegalArgumentException e) { throw new LoginFailureException(e.getMessage(), e); } } catch (JargonException e) { throw new IRODSExceptionMappingService().map(e); } }
From source file:com.denimgroup.threadfix.service.defects.utils.bugzilla.BugzillaClientImpl.java
/** * @param client/* w w w .j av a 2 s.c o m*/ * @throws XmlRpcException */ private String login(XmlRpcClient client) throws XmlRpcException { Map<String, String> loginMap = new HashMap<>(); loginMap.put("login", this.username == null ? "" : this.username); loginMap.put("password", this.password == null ? "" : this.password); loginMap.put("rememberlogin", "Bugzilla_remember"); Object[] loginArray = new Object[1]; loginArray[0] = loginMap; Object loginResult; try { loginResult = client.execute("User.login", loginArray); } catch (IllegalArgumentException e2) { if (e2.getMessage().contains("Host name may not be null")) { return AbstractDefectTracker.BAD_CONFIGURATION; } else { LOG.error("Encountered IllegalArgumentException", e2); return AbstractDefectTracker.BAD_CONFIGURATION; } } if (loginResult == null) { return null; } else { return loginResult.toString(); } }
From source file:DecimalFormatDemo.java
/** Reformats the input number and displays result. */ public void reformat() { try {//from w ww.java 2 s . c o m NumberFormat nf = NumberFormat.getNumberInstance(availableLocales.getCurrent()); DecimalFormat df = (DecimalFormat) nf; df.applyPattern(currentPattern); result.setForeground(Color.black); result.setText(df.format(currentNumber)); } catch (IllegalArgumentException iae) { result.setForeground(Color.red); result.setText("Illegal Pattern: " + iae.getMessage()); } }
From source file:com.xpn.xwiki.render.filter.StyleFilter.java
public void handleMatch(StringBuffer buffer, MatchResult result, FilterContext context) { String command = result.group(1); if (command != null) { // {$peng} are variables not macros. if (!command.startsWith("$")) { MacroParameter mParams = context.getMacroParameter(); switch (result.groups()) { case 3: mParams.setContent(result.group(3)); mParams.setContentStart(result.beginOffset(3)); mParams.setContentEnd(result.endOffset(3)); case 2: mParams.setParams(result.group(2)); }/*from w ww. j a v a 2 s . com*/ mParams.setStart(result.beginOffset(0)); mParams.setEnd(result.endOffset(0)); // @DANGER: recursive calls may replace macros in included source code try { if (command.equals("style") && (mParams.getContent() != null)) { // We need to handle recursivity here String content = mParams.getContent(); Pattern pattern = Pattern.compile("\\{" + command + ".*?\\}"); // This code allows to find the real end tag Matcher matcher = pattern.matcher(content); int startTagNumber = 1; int endPosition = content.length(); while (matcher.find()) { String match = matcher.group(); if (match.equals("{" + command + "}")) { startTagNumber--; if (startTagNumber == 0) { endPosition = matcher.start(); break; } } else { startTagNumber++; } } // Get the content up to the real end tag String realContent = content.substring(0, endPosition); // Execute any nested macros and filters mParams.setContent(realContent); Writer writer = new StringBufferWriter(buffer); Macro macro = (Macro) getMacroRepository().get(command); // Execute the macro resulting content macro.execute(writer, mParams); if (content.length() != endPosition) { // Get the content after the real end tag String nextContent = content.substring(endPosition + 2 + command.length()) + "{style}"; // Execute other macros on content after the real end tag writer.append(nextContent); } } else if (getMacroRepository().containsKey(command)) { Macro macro = (Macro) getMacroRepository().get(command); // recursively filter macros within macros if (null != mParams.getContent()) { mParams.setContent(mParams.getContent()); } Writer writer = new StringBufferWriter(buffer); macro.execute(writer, mParams); } else { buffer.append(result.group(0)); return; } } catch (IllegalArgumentException e) { buffer.append("<div class=\"error\">" + command + ": " + e.getMessage() + "</div>"); } catch (Throwable e) { log.warn("MacroFilter: unable to format macro: " + result.group(1), e); buffer.append("<div class=\"error\">" + command + ": " + e.getMessage() + "</div>"); return; } } else { buffer.append("<"); buffer.append(command.substring(1)); buffer.append(">"); } } else { buffer.append(result.group(0)); } }
From source file:com.steeleforge.aem.ironsites.i18n.taglib.I18nHelperTag.java
public void setSource(String source) throws JspException { try {// www . ja v a 2s . c om this.source = Source.valueOf(source.toUpperCase()); } catch (IllegalArgumentException e) { LOG.error("Source must match: " + Arrays.toString(Source.values()), e.getMessage()); throw new JspException(e); } }
From source file:edu.vt.middleware.ldap.cli.AbstractCli.java
/** * Parses command line options and dispatches to the requested action, or the * default action if no action is specified. * * @param args command line arguments//from w w w . j a v a 2 s . c o 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, false); 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 (RuntimeException rex) { throw rex; } catch (Exception ex) { System.err.println("Operation failed:"); ex.printStackTrace(System.err); } }
From source file:io.cloudslang.content.httpclient.build.URIBuilder.java
public URI buildURI() { try {/*from w w w . j av a 2s.c om*/ //validate as URL new URL(url); } catch (MalformedURLException e) { throw new IllegalArgumentException("the value '" + url + "' is not a valid URL", e); } org.apache.http.client.utils.URIBuilder uriBuilder; try { uriBuilder = new org.apache.http.client.utils.URIBuilder(url); } catch (URISyntaxException e) { throw new IllegalArgumentException("the value '" + url + "' is not a valid URI", e); } boolean bEncodeQueryParams = !Boolean.parseBoolean(queryParamsAreURLEncoded); boolean bEncodeQueryParamsAsForm = Boolean.parseBoolean(queryParamsAreFormEncoded); if (!StringUtils.isEmpty(queryParams)) { try { if (bEncodeQueryParamsAsForm) { uriBuilder.addParameters( (List<NameValuePair>) Utils.urlEncodeMultipleParams(queryParams, bEncodeQueryParams)); } else { uriBuilder.setCustomQuery(Utils.urlEncodeQueryParams(queryParams, bEncodeQueryParams)); } } catch (IllegalArgumentException ie) { throw new IllegalArgumentException(HttpClientInputs.QUERY_PARAMS_ARE_URLENCODED + " is 'false' but queryParams are not properly encoded. " + ie.getMessage(), ie); } } try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not build '" + HttpClientInputs.URL + "' for " + url + " and queries " + queryParamsAreURLEncoded, e); } }
From source file:de.steilerdev.myVerein.server.controller.user.MessageController.java
/** * This function retrieves all unread messages of a user. The function is invoked bu GETting the URI /api/user/message. * @param currentUser The currently logged in user. * @return An HTTP response with a status code, together with the JSON list-object of all unread messages, or only an error code if an error occurred. *///www . j a v a 2 s. com @RequestMapping(produces = "application/json", method = RequestMethod.GET) public ResponseEntity<List<Message>> getMessages(@CurrentUser User currentUser, @RequestParam(required = false) String all) { logger.trace("[{}] Getting unread messages", currentUser); List<Message> messages = messageRepository.findAllByPrefixedReceiverIDAndMessageStatus( Message.receiverIDForUser(currentUser), Message.MessageStatus.PENDING); if (messages == null) { logger.debug("[{}] Unable to find any undelivered messages", currentUser); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } else { messages.parallelStream().forEach(message -> message.setDelivered(currentUser)); if (all != null && !all.isEmpty()) { logger.debug("[{}] Retrieving all messages", currentUser); messages.addAll(messageRepository.findAllByPrefixedReceiverIDAndMessageStatus( Message.receiverIDForUser(currentUser), Message.MessageStatus.DELIVERED)); messages.addAll(messageRepository.findAllByPrefixedReceiverIDAndMessageStatus( Message.receiverIDForUser(currentUser), Message.MessageStatus.READ)); } try { messageRepository.save(messages); messages.replaceAll(Message::getSendingObjectOnlyId); logger.info("[{}] Returning messages", currentUser); return new ResponseEntity<>(messages, HttpStatus.OK); } catch (IllegalArgumentException e) { logger.warn("[" + currentUser + "] Unable to save messages for " + currentUser.getEmail() + ": " + e.getMessage()); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } } }
From source file:com.comphenix.xp.commands.CommandExperienceMod.java
private void handleQueryItem(CommandSender sender, String[] args, int offset) { Integer type = plugin.getActionTypes().getType(CommandUtilities.getSafe(args, offset)); // Make sure it's valid if (type == null) { plugin.respond(sender,//from w w w .j a v a2 s.c om ChatColor.RED + "Unknown action type: " + CommandUtilities.getSafe(args, offset)); return; } try { String text = StringUtils.join(args, " ", offset + 1, args.length); Query query = itemParser.parse(text); // Determine player rewards List<Action> results = plugin.getPlayerReward(getPlayer(sender), type, query); // Finally, display query result displayActions(sender, results); } catch (IllegalArgumentException e) { plugin.respond(sender, ChatColor.RED + "Query parsing error: " + e.getMessage()); } catch (ParsingException e) { plugin.respond(sender, ChatColor.RED + "Query parsing error: " + e.getMessage()); } }
From source file:com.kii.cloud.sync.CloudStorage.java
@Override public int register(String email, String password, String country, String nickName, String mobile) { if (TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) { return SyncMsg.ERROR_INVALID_INPUT; }/*from w ww. ja v a2s .c om*/ KiiUser user = new KiiUser(); String userName = "cloud" + System.currentTimeMillis(); try { // auto generate the username user.setUsername(userName); user.setEmail(email); if (!TextUtils.isEmpty(country)) { user.put(PROPERTY_COUNTRY, country); } if (!TextUtils.isEmpty(nickName)) { user.setName(nickName); } if (!TextUtils.isEmpty(mobile)) { user.setName(mobile); } } catch (IllegalArgumentException e) { Log.e(TAG, "IllegalArgumentException:" + e.getMessage()); return SyncMsg.ERROR_INVALID_INPUT; } catch (JSONException e) { Log.e(TAG, "JSONException:" + e.getMessage()); return SyncMsg.ERROR_INVALID_INPUT; } UserResult result; try { result = mUserMgr.createUser(user, password); } catch (CloudExecutionException e) { return SyncMsg.ERROR_INVALID_INPUT; } catch (IOException e) { return SyncMsg.ERROR_IO; } catch (IllegalArgumentException e) { Log.e(TAG, "JSONException:" + e.getMessage()); return SyncMsg.ERROR_INVALID_INPUT; } catch (JSONException e) { Log.e(TAG, "JSONException:" + e.getMessage()); return SyncMsg.ERROR_INVALID_INPUT; } user = result.getKiiUser(); if (userName.compareTo(user.getUsername()) == 0) return SyncMsg.OK; return SyncMsg.ERROR_UNKNOWN_STATUSCODE; }