Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:jp.primecloud.auto.zabbix.client.UserClientTest.java

@Test
@Ignore//from w  w  w  . j  a  va 2  s .c  o m
public void testDelete() {
    // userid??????
    try {
        client.user().delete(null);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:com.marklogic.contentpump.CompressedDocumentReader.java

@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
    if (zipIn == null) {
        hasNext = false;/* w  w w  . jav a2  s . c o  m*/
        return false;
    }
    if (codec == CompressionCodec.ZIP) {
        ZipEntry zipEntry;
        ZipInputStream zis = (ZipInputStream) zipIn;
        while (true) {
            try {
                zipEntry = zis.getNextEntry();
                if (zipEntry == null) {
                    break;
                }
                if (zipEntry.getSize() == 0) {
                    continue;
                }
                subId = zipEntry.getName();
                String uri = makeURIForZipEntry(file, subId);
                if (setKey(uri, 0, 0, true)) {
                    return true;
                }
                setValue(zipEntry.getSize());
                return true;
            } catch (IllegalArgumentException e) {
                LOG.warn("Skipped a zip entry in : " + file.toUri() + ", reason: " + e.getMessage());
            }
        }
    } else if (codec == CompressionCodec.GZIP) {
        setValue(0);
        zipIn.close();
        zipIn = null;
        hasNext = false;
        return true;
    } else {
        return false;
    }
    if (iterator != null && iterator.hasNext()) {
        close();
        initStream(iterator.next());
        return nextKeyValue();
    } else {
        hasNext = false;
        return false;
    }
}

From source file:com.pgcraft.spectatorplus.arenas.ArenaSetup.java

/**
 * Switch to the next setup step.//from  w  w  w.  j  av  a 2 s. c o  m
 *
 * @param location The selected location for this step. {@code null} if it's the first step.
 */
public void next(Location location) {
    step++;

    Validate.isTrue(step <= 0 || location != null, "The location is required for the second and third steps.");

    Player player = Bukkit.getPlayer(playerID);
    Spectator spectator = SpectatorPlus.get().getPlayerData(playerID);

    if (player == null || !player.isOnline()) {
        PluginLogger.warning(
                "Arena setup was executed for an offline player (UUID {0})! This is not a normal thing. Aborting setup.",
                playerID);
        spectator.setArenaSetup(null);

        return;
    }

    switch (step) {
    case 0:
        SpectatorPlus.get().sendMessage(player,
                ChatColor.GOLD + "You just entered arena setup mode for the arena " + ChatColor.RED + arenaName
                        + ChatColor.GOLD + ".",
                true);
        player.sendMessage(ChatColor.GOLD
                + "You'll have to mark the two opposite corners of the arena, which is a 3D rectangular structure.");
        player.sendMessage(ChatColor.GOLD + "Punch the " + ChatColor.RED + "first corner" + ChatColor.GOLD
                + " of the arena.");
        player.sendMessage(ChatColor.GRAY + "You can also use the command " + ChatColor.WHITE
                + "/spec arena corner" + ChatColor.GRAY + " to set the corner at your current location.");
        break;

    case 1:
        corner1 = location;
        SpectatorPlus.get().sendMessage(player, ChatColor.GOLD + "Now, punch the " + ChatColor.RED
                + "second corner" + ChatColor.GOLD + " of the arena, at the opposite corner.", true);
        player.sendMessage(ChatColor.GRAY + "You can still use the " + ChatColor.WHITE + "/spec arena corner"
                + ChatColor.GRAY + " command.");
        break;

    case 2:
        corner2 = location;
        try {
            SpectatorPlus.get().getArenasManager().registerArena(new Arena(arenaName, corner1, corner2));
            SpectatorPlus.get().sendMessage(player,
                    "The arena " + ChatColor.RED + arenaName + ChatColor.GOLD + " was successfully registered!",
                    true);
        } catch (IllegalArgumentException e) {
            SpectatorPlus.get().sendMessage(player, ChatColor.RED + "Cannot register the arena.", true);
            player.sendMessage(ChatColor.RED + "Error: " + e.getMessage());
        }
        spectator.setArenaSetup(null);
        break;
    }
}

From source file:com.nec.harvest.service.impl.UserDetailServiceImpl.java

/**
 * Locates the user based on the username. In the actual implementation, the
 * search may possibly be case sensitive, or case insensitive depending on
 * how the implementation instance is configured. In this case, the
 * <code>UserDetails</code> object that comes back may have a username that
 * is of a different case than what was actually requested..
 * /* w  w w.  j a v  a2 s.  c  om*/
 * @param username
 *            the username identifying the user whose data is required.
 * 
 * @return a fully populated user record (never <code>null</code>)
 * 
 * @throws UsernameNotFoundException
 *             if the user could not be found or the user has no
 *             GrantedAuthority
 */
@Override
@Transactional(readOnly = true, rollbackFor = {
        HibernateException.class }, propagation = Propagation.REQUIRES_NEW)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    if (logger.isDebugEnabled()) {
        logger.debug("Locates the user based on the username or usercode");
    }

    // The username or usercode identifying the user whose data is required
    if (StringUtils.isEmpty(username)) {
        logger.warn("The username or usercode identifying the user whose data is required");

        // ??????????
        throw new HarvestAuthenticationException(
                "??????????");
    }

    // Trying to authenticate by username or usercode {} and password [ protected ]
    logger.info("Trying to authenticate by username or usercode {} and password [ protected ]", username);

    try {
        user = userService.findByUsrCode(username);
    } catch (IllegalArgumentException ex) {
        // User's code must not be null or empty
        logger.warn(ex.getMessage());

        // ??????????
        throw new HarvestAuthenticationException(
                "??????????");
    } catch (ObjectNotFoundException ex) {
        logger.warn(ex.getMessage());

        // ??????????
        throw new HarvestAuthenticationException(
                "??????????");
    } catch (org.hibernate.ObjectNotFoundException ex) {
        logger.warn(ex.getMessage());

        // ?????????????
        throw new OrganizationNotFoundException(
                "?????????????");
    } catch (TooManyObjectsException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        throw new TooManyObjectsException("???????????");
    } catch (ConnectionException | ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        throw new ServiceException("???????????");
    }

    // Wait seconds... The system trying to check the granted authorities for authenticating user {usernameOrUsrCode}
    logger.info(
            "Please wait second(s)... The system trying to check the granted authorities for authenticating user "
                    + username);

    // ?
    // 1?2?3??4
    int kengenkodo = 0;
    String usrKbn = user.getUsrKbn();
    if (StringUtils.isNotEmpty(usrKbn)) {
        kengenkodo = Integer.parseInt(usrKbn);
    }

    // The authorities that should be granted to the caller if they
    // presented the correct username and password and the user is enabled. Not null.
    Collection<GrantedAuthority> authorities = getRolesToBeGranted(kengenkodo);

    // Construct the User with the details required by DaoAuthenticationProvider
    return new org.springframework.security.core.userdetails.User(username, user.getPassword(), authorities);
}

From source file:bear.core.Stage.java

public Collection<? extends Address> getHostsForRoles(List<String> stringRoles) {
    List<Role> roles;

    try {//from  ww  w.j  ava2  s  .  c o  m
        roles = newArrayList(transform(stringRoles, forMap(stages.get().rolenameToRole)));
    } catch (IllegalArgumentException e) {
        throw new StagesException("role not found: " + e.getMessage() + " on stage '" + name + "'");
    }

    LinkedHashSet<Address> hashSet = null;

    hashSet = Sets.newLinkedHashSet(concat(transform(roles, forMap(stages.get().roleToAddresses.asMap()))));

    return Lists.newArrayList(Sets.intersection(hashSet, addresses));
}

From source file:jp.primecloud.auto.zabbix.client.UserClientTest.java

@Test
@Ignore//from   w w w  .  ja  va 2s .c  o  m
public void testCreate() {
    // alias??????
    UserCreateParam param = new UserCreateParam();
    param.setName("name1");
    try {
        client.user().create(param);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:jp.primecloud.auto.zabbix.client.UserClientTest.java

@Test
@Ignore/*from   w ww.  ja v a2s .com*/
public void testUpdate() {
    // userid??????
    UserUpdateParam param = new UserUpdateParam();
    param.setAlias("alias1");
    try {
        client.user().update(param);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:com.puppycrawl.tools.checkstyle.JavadocPropertiesGeneratorTest.java

@Test
public void testJavadocParseError() throws Exception {
    try {/*from w  w  w.  ja  va  2  s  . co m*/
        JavadocPropertiesGenerator.main(getPath("InputJavadocPropertiesGeneratorJavadocParseError.java"),
                "--destfile", DESTFILE.getAbsolutePath());
        fail("Exception was expected");
    } catch (IllegalArgumentException ex) {
        assertTrue("Invalid error message",
                ex.getMessage().contains("mismatched input '<EOF>' expecting JAVADOC_INLINE_TAG_END"));
    }
    assertEquals("File '" + DESTFILE + "' must be empty", 0, FileUtils.sizeOf(DESTFILE));
}

From source file:de.ailis.jasdoc.tags.TagParser.java

/**
 * Parses the specified JavaScript documentation comment and returns all the
 * tags parsed from it.//from  www.j  a v a  2s  .  c  o m
 * 
 * @param comment
 *            The comment to parse.
 * @param additionals
 *            Additional tags to add.
 * @param node
 *            The JavaScript node for fetching the source position if an
 *            error occurred.
 * @return The tags parsed from the comment.
 */
public Tags parse(final String comment, final Tag[] additionals, final AstNode node) {
    final TypeFactory typeFactory = this.typeFactory;
    final Tags tags = new Tags();
    if (comment == null || comment.length() == 0)
        return tags;

    // Prepare the comment string by trimming the comment block and all
    // comment lines
    String data = trimLines(trimBlock(comment));

    // If comment doesn't start with an tag then prepend a
    // description tag to satisfy the parser (Because
    // all unannotated text is considered to be part of the description).
    if (!data.matches("(?s)^\\s*@.*"))
        data = "@description\n" + data;

    // Split the data into tag blocks and iterate over them.
    final String[] blocks = data.split("(?m)^\\s*@");
    for (final String block : blocks) {
        final Matcher matcher = ANNOTATION_PATTERN.matcher(block);
        if (!matcher.matches())
            continue;

        // Split block into an tag name and an argument
        final String annoName = matcher.group(1);
        final String annoArg = matcher.group(2).trim();

        // Process tags (Unknown tags are silently ignored)
        try {
            if ("description".equals(annoName))
                tags.add(new DescriptionTag(annoArg));
            else if ("class".equals(annoName))
                tags.add(new ClassTag(annoArg));
            else if ("interface".equals(annoName))
                tags.add(new InterfaceTag());
            else if ("namespace".equals(annoName))
                tags.add(new NamespaceTag(annoArg));
            else if ("param".equals(annoName))
                tags.add(new ParamTag(annoArg, typeFactory));
            else if ("return".equals(annoName))
                tags.add(new ReturnTag(annoArg, typeFactory));
            else if ("type".equals(annoName))
                tags.add(new TypeTag(annoArg, typeFactory));
            else if ("extends".equals(annoName))
                tags.add(new ExtendsTag(annoArg, typeFactory));
            else if ("augments".equals(annoName))
                tags.add(new ExtendsTag(annoArg, typeFactory));
            else if ("implements".equals(annoName))
                tags.add(new ImplementsTag(annoArg, typeFactory));
            else if ("deprecated".equals(annoName))
                tags.add(new DeprecatedTag(annoArg));
            else if ("enum".equals(annoName))
                tags.add(new EnumTag(annoArg, typeFactory));
            else if ("constructor".equals(annoName))
                tags.add(new ConstructorTag());
            else if ("private".equals(annoName))
                tags.add(new PrivateTag());
            else if ("protected".equals(annoName))
                tags.add(new ProtectedTag());
            else if ("const".equals(annoName))
                tags.add(new ConstTag());
            else if ("final".equals(annoName))
                tags.add(new FinalTag());
            else if ("constant".equals(annoName))
                tags.add(new ConstTag());
            else if (this.config.isAuthorIncluded() && "author".equals(annoName))
                tags.add(new AuthorTag(annoArg));
            else if ("since".equals(annoName))
                tags.add(new SinceTag(annoArg));
            else if ("see".equals(annoName))
                tags.add(new SeeTag(annoArg));
            else if ("version".equals(annoName))
                tags.add(new VersionTag(annoArg));
            else if ("inheritDoc".equals(annoName))
                tags.add(new InheritDocTag());
        } catch (final IllegalArgumentException e) {
            LOG.warn(e.getMessage() + " in " + node.getAstRoot().getSourceName() + " line " + node.getLineno(),
                    e);
        }
    }

    // Add additional tags
    if (additionals != null)
        for (final Tag tag : additionals)
            tags.add(tag);

    return tags;
}

From source file:org.springframework.cloud.dataflow.rest.client.DataflowTemplateTests.java

@Test
public void testPrepareRestTemplateWithRestTemplateThatMissesJacksonConverter() {
    final RestTemplate providedRestTemplate = new RestTemplate();
    final Iterator<HttpMessageConverter<?>> iterator = providedRestTemplate.getMessageConverters().iterator();

    while (iterator.hasNext()) {
        if (iterator.next() instanceof MappingJackson2HttpMessageConverter) {
            iterator.remove();//from w  ww .  ja v a 2  s .  c  o m
        }
    }

    try {
        DataFlowTemplate.prepareRestTemplate(providedRestTemplate);
    } catch (IllegalArgumentException e) {
        assertEquals("The RestTemplate does not contain a required MappingJackson2HttpMessageConverter.",
                e.getMessage());
        return;
    }

    fail("Expected an IllegalArgumentException to be thrown.");
}