Example usage for java.lang IllegalArgumentException toString

List of usage examples for java.lang IllegalArgumentException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:mx.edu.ittepic.proyectofinal.ejbs.ejbUsers.java

public String newUser(String username, String password, String phone, String neigborhood, String zipcode,
        String city, String country, String state, String region, String street, String email,
        String streetnumber, String photo, String cellphone, String companyid, String roleid, String gender) {

    Message m = new Message();
    Users u = new Users();
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();//from   w ww.  java  2s .  c o  m

    Company com = entity.find(Company.class, Integer.parseInt(companyid));
    Role rol = entity.find(Role.class, Integer.parseInt(roleid));

    try {
        String cadenaoriginal = password;
        String md5 = DigestUtils.md5Hex(cadenaoriginal);

        u.setUsername(username);
        u.setPassword(md5);
        u.setPhone(phone);
        u.setNeigborhood(neigborhood);
        u.setZipcode(zipcode);
        u.setCity(city);
        u.setCountry(country);
        u.setState(state);
        u.setRegion(region);
        u.setStreet(street);
        u.setEmail(email);
        u.setStreetnumber(streetnumber);
        u.setPhoto(photo);
        u.setCellphone(cellphone);
        u.setCompanyid(com);
        u.setRoleid(rol);
        u.setGender(gender.charAt(0));
        u.setApikey("off");

        entity.persist(u);
        entity.flush();

        updateUser(u.getUserid().toString(), u.getApikey());

        m.setCode(200);
        m.setMsg("El usuario se ha registro correctamente");
        m.setDetail(u.getUserid().toString());

    } catch (IllegalArgumentException e) {
        m.setCode(503);
        m.setMsg("Error en la base de datos");
        m.setDetail(e.toString());
    } catch (TransactionRequiredException e) {
        m.setCode(503);
        m.setMsg("Error en la transaccion con la base de datos");
        m.setDetail(e.toString());
    } catch (EntityExistsException e) {
        m.setCode(400);
        m.setMsg("Hubo problemas con la base de datos");
        m.setDetail(e.toString());
    } catch (ConstraintViolationException e) {
        m.setCode(400);
        m.setMsg("Hubo problemas con la base de datos");
        m.setDetail(e.getConstraintViolations().toString());
    }

    return gson.toJson(m);
}

From source file:com.streamsets.pipeline.lib.generator.binary.BinaryDataGenerator.java

@Override
public void write(Record record) throws IOException, DataGeneratorException {
    if (closed) {
        throw new IOException("generator has been closed");
    }//www .j av  a2 s .  c  om

    Field field = record.get(fieldPath);
    if (field != null && field.getValue() != null) {
        byte[] value;
        try {
            value = field.getValueAsByteArray();
        } catch (IllegalArgumentException ex) {
            throw new DataGeneratorException(Errors.BINARY_GENERATOR_00, record.getHeader().getSourceId(),
                    fieldPath);
        }

        try {
            IOUtils.write(value, outputStream);
        } catch (IOException ex) {
            throw new DataGeneratorException(Errors.BINARY_GENERATOR_01, record.getHeader().getSourceId(),
                    ex.toString());
        }
    }
}

From source file:eionet.gdem.utils.InputFile.java

/**
 * Stores the URL of remote file./*from w  w w  . ja va2s.  c  om*/
 *
 * @param strUrl URL of input file
 * @throws MalformedURLException Invalid URL.
 */
private void setURL(String strUrl) throws MalformedURLException {
    try {
        URI uri = new URI(escapeSpaces(strUrl));
        parseUri(uri);

        this.url = uri.toURL();

    } catch (URISyntaxException ue) {
        throw new MalformedURLException(ue.toString());
    } catch (IllegalArgumentException ae) {
        throw new MalformedURLException(ae.toString());
    }
}

From source file:edu.umd.cs.submitServer.MultipartRequest.java

public double getDoubleParameter(String name) throws InvalidRequiredParameterException {
    String param = getStringParameter(name);
    if (param == null || param.equals("")) {
        throw new InvalidRequiredParameterException(name + " is a required parameter");
    }//from w  w  w .j av  a 2s  . c  om
    double d;
    try {
        d = Double.parseDouble(param);
        return d;
    } catch (IllegalArgumentException e) {
        throw new InvalidRequiredParameterException("name was of an invalid form: " + e.toString());
    }
}

From source file:edu.umd.cs.submitServer.MultipartRequest.java

public Timestamp getTimestampParameter(String name) throws InvalidRequiredParameterException {
    String param = getStringParameter(name);
    if (param == null || param.equals("")) {
        throw new InvalidRequiredParameterException(name + " is a required parameter");
    }//  w ww.  j  a  v a 2 s. co m
    Timestamp timestamp = null;
    try {
        timestamp = Timestamp.valueOf(param);
    } catch (IllegalArgumentException e) {
        throw new InvalidRequiredParameterException("name was of an invalid form: " + e.toString());
    }
    return timestamp;
}

From source file:org.opennaas.itests.roadm.shell.ConnectionsKarafCommandsTest.java

public Object executeCommandWithResponse(String command) throws Exception {
    // Run some commands to make sure they are installed properly
    ByteArrayOutputStream outputError = new ByteArrayOutputStream();
    PrintStream psE = new PrintStream(outputError);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(output);
    CommandSession cs = commandProcessor.createSession(System.in, ps, psE);
    Object commandOutput = null;/*from w w  w. ja  v a 2s.  c  o m*/
    try {
        commandOutput = cs.execute(command);
        return commandOutput;
    } catch (IllegalArgumentException e) {
        Assert.fail("Action should have thrown an exception because: " + e.toString());
    } catch (NoSuchMethodException a) {
        log.error("Method for command not found: " + a.getLocalizedMessage());
        Assert.fail("Method for command not found.");
    } finally {
        cs.close();
    }
    return commandOutput;
}

From source file:podd.resources.services.LocalFileAttachmentService.java

@Override
protected void prePostAuthorisation(Representation entity) {
    LOGGER.debug("File attachment service");
    errorMap = new HashMap<String, String>();
    String pid = "";
    poddObject = null;/*from w w  w  . j  a va 2s.  c om*/

    try {
        loadFormData(entity);
        pid = RDFHelper.getLocalNameForURIString(objectURI);
    } catch (IllegalArgumentException e) {
        getResponse().setStatus(CLIENT_ERROR_BAD_REQUEST);
        final String msg = "Invalid URI: " + objectURI + ".  " + e.getMessage();
        LOGGER.error(msg);
        errorMap.put("errorMessage", msg);
        auditLogHelper.auditAction(ERROR, authenticatedUser, "File Attachment Service: " + msg, e.toString());
    }
    if (errorMap.isEmpty()) {
        poddObject = loadObject(pid);
    }
}

From source file:com.streamsets.pipeline.stage.processor.jdbclookup.JdbcLookupProcessor.java

private Optional<List<Map<String, Field>>> calculateDefault(Processor.Context context,
        List<ConfigIssue> issues) {
    for (JdbcFieldColumnMapping mapping : columnMappings) {
        LOG.debug("Mapping field {} to column {}", mapping.field, mapping.columnName);
        columnsToFields.put(mapping.columnName, mapping.field);
        if (!StringUtils.isEmpty(mapping.defaultValue) && mapping.dataType == DataType.USE_COLUMN_TYPE) {
            issues.add(context.createConfigIssue(Groups.JDBC.name(), COLUMN_MAPPINGS, JdbcErrors.JDBC_53,
                    mapping.field));//from w w w .java 2 s .c  o m
        }
        columnsToDefaults.put(mapping.columnName, mapping.defaultValue);
        columnsToTypes.put(mapping.columnName, mapping.dataType);
        if (mapping.dataType == DataType.DATE) {
            try {
                DATE_FORMATTER.parseDateTime(mapping.defaultValue);
            } catch (IllegalArgumentException e) {
                issues.add(context.createConfigIssue(Groups.JDBC.name(), COLUMN_MAPPINGS, JdbcErrors.JDBC_55,
                        mapping.field, e.toString()));
            }
        } else if (mapping.dataType == DataType.DATETIME) {
            try {
                DATETIME_FORMATTER.parseDateTime(mapping.defaultValue);
            } catch (IllegalArgumentException e) {
                issues.add(context.createConfigIssue(Groups.JDBC.name(), COLUMN_MAPPINGS, JdbcErrors.JDBC_56,
                        mapping.field, e.toString()));
            }
        }
    }

    if (!issues.isEmpty()) {
        return Optional.empty();
    }

    Map<String, Field> defaultValues = new HashMap<>();

    for (String column : columnsToFields.keySet()) {
        String defaultValue = columnsToDefaults.get(column);
        DataType dataType = columnsToTypes.get(column);
        if (dataType != DataType.USE_COLUMN_TYPE) {
            Field field;
            try {
                if (dataType == DataType.DATE) {
                    field = Field.createDate(DATE_FORMATTER.parseDateTime(defaultValue).toDate());
                } else if (dataType == DataType.DATETIME) {
                    field = Field.createDatetime(DATETIME_FORMATTER.parseDateTime(defaultValue).toDate());
                } else {
                    field = Field.create(Field.Type.valueOf(columnsToTypes.get(column).getLabel()),
                            defaultValue);
                }
                defaultValues.put(column, field);
            } catch (IllegalArgumentException e) {
                issues.add(context.createConfigIssue(Groups.JDBC.name(), COLUMN_MAPPINGS, JdbcErrors.JDBC_03,
                        column, defaultValue, e));
            }
        }
    }

    return defaultValues.isEmpty() ? Optional.empty() : Optional.of(ImmutableList.of(defaultValues));
}

From source file:org.apache.ode.bpel.common.InstanceFilter.java

/**
 * Initializes properly the InstanceFilter attributes by pre-parsing the
 * filter and orderKeys strings and setting the limit. A limit inferior than
 * or equal to 0 is ignored./*from w ww .ja  v  a 2s  . c  om*/
 *
 * @param filter
 * @param orderKeys
 */
public InstanceFilter(String filter, String orderKeys, int limit) {
    init(filter);

    // Some additional validation on status values
    if (statusFilter != null) {
        for (String status : statusFilter) {
            try {
                StatusKeys.valueOf(status.toUpperCase());
            } catch (IllegalArgumentException e) {
                throw new InvalidRequestException("The status you're using in your filter isn't valid, "
                        + "only the active, suspended, error, completed, terminated and faulted status are "
                        + "valid. " + e.toString());
            }
        }
    }
    // Some additional validation on date format value
    if (startedDateFilter != null) {
        for (String ddf : startedDateFilter) {
            try {
                parseDateExpression(getDateWithoutOp(ddf));
            } catch (ParseException e) {
                throw new InvalidRequestException("Couldn't parse one of the filter date, please make "
                        + "sure it follows the ISO-8601 date or date/time standard (yyyyMMddhhmmss). "
                        + e.toString());
            }
        }
    }
    if (lastActiveDateFilter != null) {
        for (String ddf : lastActiveDateFilter) {
            try {
                parseDateExpression(getDateWithoutOp(ddf));
            } catch (ParseException e) {
                throw new InvalidRequestException("Couldn't parse one of the filter date, please make "
                        + "sure it follows the ISO-8601 date or date/time standard (yyyyMMddhhmmss). "
                        + e.toString());
            }
        }
    }

    if (orderKeys != null && orderKeys.length() > 0) {
        orders = new ArrayList<String>(3);
        for (StringTokenizer orderKeysTok = new StringTokenizer(orderKeys, " "); orderKeysTok
                .hasMoreTokens();) {
            String orderKey = orderKeysTok.nextToken();
            try {
                String justKey = orderKey;
                if (justKey.startsWith("-") || justKey.startsWith("+"))
                    justKey = orderKey.substring(1, justKey.length());
                OrderKeys.valueOf(justKey.replaceAll("-", "_").toUpperCase());
                orders.add(orderKey);
            } catch (IllegalArgumentException e) {
                throw new InvalidRequestException("One of the ordering keys isn't valid, processes can only "
                        + "be sorted by pid, name, namespace, version, status, started and last-active "
                        + "date." + e.toString());

            }
        }
    }
    if (limit < 0) {
        throw new IllegalArgumentException("Limit should be greater or equal to 0.");
    }
    this.limit = limit;
}

From source file:com.blackducksoftware.integration.hub.jenkins.maven.MavenBuildWrapper.java

private void setupAndAddMavenClasspathAction(final AbstractBuild<?, ?> build,
        final HubJenkinsLogger buildLogger) {
    try {//w ww .ja v a  2 s.  c o m
        final MavenClasspathAction mavenClasspathAction = new MavenClasspathAction();

        final BdMavenConfigurator mavenConfig = new BdMavenConfigurator(buildLogger);

        final String mavenVersion = getMavenVersion(build, mavenConfig, buildLogger);
        final StringBuilder mavenExtClasspath = new StringBuilder();
        File dependencyRecorderJar = null;
        File buildInfo = null;
        File slf4jJar = null;
        File log4jJar = null;
        File slf4jJdkBindingJar = null;
        File gsonJar = null;

        final boolean maven3orLater = MavenUtil.maven3orLater(mavenVersion);
        boolean supportedVersion = false;
        try {
            if (maven3orLater) {
                if (mavenVersion.contains("3.0")) {
                    supportedVersion = true;
                    dependencyRecorderJar = mavenConfig.jarFile(Recorder_3_0_Loader.class);
                    slf4jJar = mavenConfig.jarFile(org.slf4j.helpers.FormattingTuple.class);
                    slf4jJdkBindingJar = mavenConfig.jarFile(org.slf4j.impl.JDK14LoggerAdapter.class);
                    mavenClasspathAction.setIsRecorder30(true);
                } else if (mavenConfig.isMaven31OrLater(mavenVersion)) {
                    supportedVersion = true;
                    dependencyRecorderJar = mavenConfig.jarFile(Recorder_3_1_Loader.class);
                    mavenClasspathAction.setIsRecorder31(true);
                }
                if (supportedVersion) {
                    final String buildId = build.getId();
                    mavenClasspathAction.setBuildId(buildId);

                    final FilePath workspace = build.getWorkspace();
                    if (workspace != null) {
                        final String workingDirectory = workspace.getRemote();
                        mavenClasspathAction.setWorkingDirectory(workingDirectory);

                        buildInfo = mavenConfig.jarFile(BuildInfo.class);
                        log4jJar = mavenConfig.jarFile(Logger.class);
                        gsonJar = mavenConfig.jarFile(Gson.class);
                    } else {
                        buildLogger.error("workspace: null");
                        build.setResult(Result.UNSTABLE);
                    }
                } else {
                    buildLogger.error("Unsupported version of Maven. Maven version: " + mavenVersion);
                    build.setResult(Result.UNSTABLE);
                }
            } else {
                buildLogger.error("Unsupported version of Maven. Maven version: " + mavenVersion);
                build.setResult(Result.UNSTABLE);
            }
        } catch (final IllegalArgumentException e) {
            buildLogger.error("Failed to retrieve Maven information! " + e.toString(), e);
            build.setResult(Result.UNSTABLE);
        } catch (final IOException e) {
            buildLogger.error("Failed to retrieve Maven information! " + e.toString(), e);
            build.setResult(Result.UNSTABLE);
        } catch (final BDMavenRetrieverException e) {
            buildLogger.error("Failed to retrieve Maven information! " + e.toString(), e);
            build.setResult(Result.UNSTABLE);
        }

        if (supportedVersion) {
            // transport the necessary jars to slave
            final Node buildOn = build.getBuiltOn();
            if (buildOn == null) {
                buildLogger.error("Node build on: null");
            } else {
                FilePath remoteRootPath = new FilePath(buildOn.getRootPath(), "cache");
                remoteRootPath = new FilePath(remoteRootPath, "hub-jenkins");
                removeSnapshots(remoteRootPath);

                String pathSeparator = null;
                try {
                    final VirtualChannel channel = buildOn.getChannel();
                    if (channel == null) {
                        buildLogger.error("Channel build on: null");
                    } else {
                        pathSeparator = channel.call(new GetPathSeparator());
                    }
                } catch (final IOException e) {
                    buildLogger.error(e.toString(), e);
                } catch (final InterruptedException e) {
                    buildLogger.error(e.toString(), e);
                }
                if (StringUtils.isEmpty(pathSeparator)) {
                    pathSeparator = File.pathSeparator;
                }
                mavenClasspathAction.setSeparator(pathSeparator);

                if (dependencyRecorderJar != null) {
                    appendClasspath(build, remoteRootPath, mavenExtClasspath,
                            dependencyRecorderJar.getAbsolutePath(), buildLogger, pathSeparator);
                    if (buildInfo != null) {
                        appendClasspath(build, remoteRootPath, mavenExtClasspath, buildInfo.getAbsolutePath(),
                                buildLogger, pathSeparator);
                    }
                    if (gsonJar != null) {
                        appendClasspath(build, remoteRootPath, mavenExtClasspath, gsonJar.getAbsolutePath(),
                                buildLogger, pathSeparator);
                    }
                    if (slf4jJar != null) {
                        appendClasspath(build, remoteRootPath, mavenExtClasspath, slf4jJar.getAbsolutePath(),
                                buildLogger, pathSeparator);
                    }
                    if (slf4jJdkBindingJar != null) {
                        appendClasspath(build, remoteRootPath, mavenExtClasspath,
                                slf4jJdkBindingJar.getAbsolutePath(), buildLogger, pathSeparator);
                    }
                    if (log4jJar != null) {
                        appendClasspath(build, remoteRootPath, mavenExtClasspath, log4jJar.getAbsolutePath(),
                                buildLogger, pathSeparator);
                    }
                    mavenClasspathAction.setMavenClasspathExtension(mavenExtClasspath.toString());
                    buildLogger.debug(
                            "Hub Build Wrapper 'maven.ext.class.path' = " + mavenExtClasspath.toString());
                    build.addAction(mavenClasspathAction);
                    return;
                } else {
                    buildLogger.error("Dependency recorder Jar not found. Maven version: " + mavenVersion);
                }
            }
        }

    } catch (final Exception e) {
        buildLogger.error(e);
    }
    return;
}