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:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

private void processCommand() {
    try {/*from w w w.j  av  a  2 s.  c  o m*/
        names = command.getFreeOptionList("variables").getString();
        numberOfVariables = names.size();
        title = "";
        minTestScore = command.getPairedOptionList("xaxis").getDoubleAt("min");
        maxTestScore = command.getPairedOptionList("xaxis").getDoubleAt("max");
        showTcc = command.getSelectAllOption("person").isArgumentSelected("tcc");
        showPersonInfo = command.getSelectAllOption("person").isArgumentSelected("info");
        showPersonSe = command.getSelectAllOption("person").isArgumentSelected("se");
        showExpectedValue = command.getSelectOneOption("type").isValueSelected("expected");
        xLabel = "Theta";
        yLabel = "Probability";
        if (showExpectedValue) {
            yLabel = "Expected Value";
        }
    } catch (IllegalArgumentException ex) {
        logger.fatal(ex.getMessage(), ex);
        this.firePropertyChange("error", "", "Error - Check log for details.");
    }

}

From source file:com.sap.dirigible.runtime.registry.RepositoryServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String repositoryPath = null;
    final OutputStream out = response.getOutputStream();
    try {//from w  w w  .ja  v  a 2  s . c om
        repositoryPath = extractRepositoryPath(request);
        IEntity entity = getEntity(repositoryPath, request);
        byte[] data;
        if (entity == null) {
            ByteArrayOutputStream buff = new ByteArrayOutputStream();
            IOUtils.copy(request.getInputStream(), buff);
            data = buff.toByteArray();
            String contentType = request.getContentType();
            if (contentType == null) {
                contentType = "text/plain"; //$NON-NLS-1$
            }
            boolean isBinary = ContentTypeHelper.isBinary(contentType);
            getRepository(request).createResource(repositoryPath, data, isBinary, contentType);
        } else {
            if (entity instanceof IResource) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_RESOURCE_AT_THE_SAME_LOCATION_USE_PUT_METHOD_FOR_UPDATE);
            } else if (entity instanceof ICollection) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        THERE_IS_AN_EXISTING_COLLECTION_AT_THE_SAME_LOCATION);
            }
        }
    } catch (IllegalArgumentException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage());
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage());
    } catch (MissingResourceException ex) {
        logger.error(String.format(REQUEST_PROCESSING_FAILED_S, repositoryPath) + ex.getMessage());
        response.sendError(HttpServletResponse.SC_NO_CONTENT, ex.getMessage());
    } finally {
        out.flush();
        out.close();
    }

}

From source file:com.sfs.upload.AdobeShareFileUploadImpl.java

/**
 * Upload the identified File to the defined storage pool.
 *
 * @param file the file//from www .  j av  a  2  s.co  m
 *
 * @return the file upload details
 *
 * @throws FileUploadException the file upload exception
 */
public final FileUploadDetails upload(final File file) throws FileUploadException {
    if (file == null) {
        throw new FileUploadException("The File object cannot be null");
    }
    if (!file.exists()) {
        throw new FileUploadException("No file exists to upload");
    }
    if (StringUtils.isBlank(this.apiKey)) {
        throw new FileUploadException("An Adobe Share API key is required");
    }
    if (StringUtils.isBlank(this.apiSharedSecret)) {
        throw new FileUploadException("An Adobe Share shared secret is required");
    }
    if (StringUtils.isBlank(this.userName)) {
        throw new FileUploadException("An Adobe Share username is required");
    }
    if (StringUtils.isBlank(this.password)) {
        throw new FileUploadException("An Adobe Share password is required");
    }

    final Date currentDate = Calendar.getInstance().getTime();
    // Add a prefix to ensure that there isn't a duplicate file name issue.
    final String format = "yyyyMMddhhmm_";
    final String fileName = Formatter.numericDate(currentDate, format) + file.getName();

    ShareAPI shareAPI = new ShareAPI(this.apiKey, this.apiSharedSecret);
    ShareAPIUser shareUser = new ShareAPIUser(this.userName, this.password);
    ShareAPINode shareNode = new ShareAPINode();

    FileUploadDetails details = null;

    try {
        logger.info("Logging into Acrobat.com");
        shareAPI.login(shareUser);
        // Upload the file to Adobe Share
        logger.info("Uploading file");
        shareNode = shareAPI.addFile(shareUser, file, fileName, "", null, true);
        logger.info("Changing privileges");
        // Set this node to be public (shared)
        shareAPI.shareFile(shareUser, shareNode, new ArrayList<String>(), userName, 2);
        logger.info("Logging out");
        shareAPI.logout(shareUser);

        if (shareNode != null) {
            details = new FileUploadDetails();
            details.setFileName(file.getName());
            details.setFileSize(file.length());
            details.setUrl(shareNode.getRecipientUrl());
        }
    } catch (HttpException he) {
        throw new FileUploadException("Error performing HTTP upload: " + he.getMessage());
    } catch (IOException ioe) {
        throw new FileUploadException("Error accessing file to upload: " + ioe.getMessage());
    } catch (ShareAPIException sapie) {
        throw new FileUploadException("Error interacting with Adobe Share: " + sapie.getMessage());
    } catch (IllegalArgumentException iae) {
        throw new FileUploadException("Error uploading file: " + iae.getMessage());
    }
    return details;
}

From source file:fi.koku.lok.LogViewController.java

@ActionMapping(params = "action=viewLog")
public void doSearchArchive(@ModelAttribute(value = "logSearchCriteria") LogSearchCriteria criteria,
        BindingResult result, @RequestParam(value = "visited") String visited, ActionResponse response) {

    if (visited != null) {
        response.setRenderParameter("visited", visited);
    }//from   ww  w.  j ava  2 s.c om

    // If something goes wrong in serializing the criteria, the portlet must not
    // die and the portlet must not query the log service
    try {
        response.setRenderParameter("logSearchCriteria", criteriaSerializer.getAsText(criteria));
    } catch (IllegalArgumentException e) {
        log.error(e.getMessage());
    }

    response.setRenderParameter("action", "viewLog");
}

From source file:it.unibas.spicygui.controllo.tree.ActionDeleteDuplicateSetCloneNode.java

public void actionPerformed(ActionEvent e) {
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) jTree.getLastSelectedPathComponent();
    TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject();
    INode iNode = adapter.getINode();//  w w w  .  j  ava2 s . c o  m
    PathExpression pathExpression = pathGenerator.generatePathFromRoot(iNode);
    try {
        if (logger.isDebugEnabled())
            logger.debug(dataSource);
        if (logger.isDebugEnabled())
            logger.debug(pathExpression);
        dataSource.removeDuplication(pathExpression);
        recreateTree();
    } catch (IllegalArgumentException iae) {
        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                NbBundle.getMessage(Costanti.class, Costanti.DELETE_DUPLICATION_NO) + ": " + iae.getMessage(),
                DialogDescriptor.ERROR_MESSAGE));
    }
}

From source file:cz.cuni.mff.ufal.dspace.app.xmlui.aspect.administrative.ControlPanelSignedLicenses.java

private Table create_table(Division div) throws WingException {
    String baseURL = contextPath + "/admin/epeople?";
    // table//w  w  w  . ja  v a2  s .c om
    Table wftable = div.addTable("workspace_items", 1, 4, "table-condensed");

    try {
        Row wfhead = wftable.addRow("", Row.ROLE_HEADER, "font_smaller");

        // table items - because of GUI not all columns could be shown
        wfhead.addCellContent("ID");
        wfhead.addCellContent("DATE");
        wfhead.addCellContent("USERNAME");
        wfhead.addCellContent("LICENSE");
        wfhead.addCellContent("ITEM");
        wfhead.addCellContent("BITSTREAM");
        wfhead.addCellContent("EXTRA METADATA");

        IFunctionalities functionalityManager = DSpaceApi.getFunctionalityManager();
        functionalityManager.openSession();
        java.util.List<LicenseResourceUserAllowance> licenses = functionalityManager.getSignedLicensesByDate();

        // hack for group by /////////

        /* we don't need group by now
         * 
        List<String> keys = new ArrayList<String>();
        List<LicenseResourceUserAllowance> licenses_group_by = new ArrayList<LicenseResourceUserAllowance>();
        for (LicenseResourceUserAllowance license : licenses) {
           String createdOn = DateFormatUtils.format(license.getCreatedOn(), "ddMMyyyyhhmm");
           String epersonID = "" + license.getUserRegistration().getEpersonId();
           String licenseID = "" + license.getLicenseResourceMapping().getLicenseDefinition().getLicenseId();
           String key = createdOn + ":" + epersonID + ":" + licenseID;
           if(!keys.contains(key)) {
              keys.add(key);
              licenses_group_by.add(license);
           }
           if(licenses_group_by.size()>=MAX_TO_SHOW) break;
        } */

        /////////////////////////////

        int cnt = 1;
        for (LicenseResourceUserAllowance license : licenses) {
            int bitstreamID = license.getLicenseResourceMapping().getBitstreamId();
            LicenseDefinition ld = license.getLicenseResourceMapping().getLicenseDefinition();
            UserRegistration ur = license.getUserRegistration();
            Date signingDate = license.getCreatedOn();

            Row r = wftable.addRow(null, null, "font_smaller bold");
            String id = DateFormatUtils.format(signingDate, "yyyyMMddhhmmss") + "-" + ur.getEpersonId() + "-"
                    + bitstreamID;
            r.addCellContent(id);

            r.addCellContent(DateFormatUtils.format(signingDate, "yyyy-MM-dd hh:mm:ss"));

            String eperson_id = String.format("%d [%s]", ur.getEpersonId(), ur.getEmail());
            String url = baseURL + "submit_edit&epersonID=" + ur.getEpersonId();
            r.addCell().addXref(url, eperson_id);

            r.addCell().addXref(ld.getDefinition(), ld.getName());

            Bitstream bitstream = Bitstream.find(context, bitstreamID);
            Item item = (Item) bitstream.getParentObject();

            String base = ConfigurationManager.getProperty("dspace.url");
            StringBuffer itemLink = new StringBuffer().append(base).append(base.endsWith("/") ? "" : "/")
                    .append("/handle/").append(item.getHandle());

            r.addCell().addXref(itemLink.toString(), "" + item.getID());

            StringBuffer bitstreamLink = new StringBuffer().append(base).append(base.endsWith("/") ? "" : "/")
                    .append("bitstream/handle/").append(item.getHandle()).append("/")
                    .append(URLEncoder.encode(bitstream.getName(), "UTF8")).append("?sequence=")
                    .append(bitstream.getSequenceID());
            r.addCell().addXref(bitstreamLink.toString(), "" + bitstream.getID());

            Cell c = r.addCell();
            List<UserMetadata> extraMetaData = functionalityManager.getUserMetadata_License(ur.getEpersonId(),
                    license.getTransactionId());
            for (UserMetadata metadata : extraMetaData) {
                c.addHighlight("label label-info font_smaller")
                        .addContent(metadata.getMetadataKey() + ": " + metadata.getMetadataValue());
            }

            if (++cnt > MAX_TO_SHOW) {
                break;
            }
        }

        functionalityManager.closeSession();

    } catch (IllegalArgumentException e1) {
        wftable.setHead("No items - " + e1.getMessage());
    } catch (Exception e2) {
        wftable.setHead("Exception - " + e2.toString());
    }

    return wftable;
}

From source file:org.openscore.content.httpclient.build.URIBuilder.java

public URI buildURI() {
    try {//  w  ww. j a v a2  s  . c  o  m
        //validate as URL
        new URL(url);
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("could not parse " + 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("could not parse " + url + " as a URI", e);
    }

    boolean bEncodeQueryParams = !Boolean.parseBoolean(queryParamsAreURLEncoded);

    if (!StringUtils.isEmpty(queryParams)) {
        try {
            uriBuilder.addParameters(
                    (List<NameValuePair>) Utils.urlEncodeMultipleParams(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:io.wcm.config.core.management.impl.override.ParameterOverrideInfoLookup.java

/**
 * Adds map containing parameter override definitions.
 * Can be called multiple times. New calls do not override settings from previous calls, only add new settings.
 * Thus maps with highest priority should be added first.
 * @param overrideMap Override map/*  ww  w .j  av  a2s .co  m*/
 */
public void addOverrideMap(Map<String, String> overrideMap) {
    if (sealed) {
        throw new IllegalStateException("Instance is sealed.");
    }
    for (Map.Entry<String, String> entry : overrideMap.entrySet()) {
        try {
            ParameterOverrideInfo info = new ParameterOverrideInfo(entry.getKey());
            if (info.isOverrideSystemDefault()) {
                putMapIfNotExsits(overrideSystemDefaultMap, info.getParameterName(), entry.getValue());
            } else if (StringUtils.isNotEmpty(info.getConfigurationId())) {
                Map<String, String> overrideForceScopeMapEntry = overrideForceScopeMap
                        .get(info.getConfigurationId());
                if (overrideForceScopeMapEntry == null) {
                    overrideForceScopeMapEntry = new HashMap<>();
                    overrideForceScopeMap.put(info.getConfigurationId(), overrideForceScopeMapEntry);
                }
                putMapIfNotExsits(overrideForceScopeMapEntry, info.getParameterName(), entry.getValue());
                if (info.isLocked()) {
                    Set<String> lockedParameterNamesScopeMapEntry = lockedParameterNamesScopeMap
                            .get(info.getConfigurationId());
                    if (lockedParameterNamesScopeMapEntry == null) {
                        lockedParameterNamesScopeMapEntry = new HashSet<>();
                        lockedParameterNamesScopeMap.put(info.getConfigurationId(),
                                lockedParameterNamesScopeMapEntry);
                    }
                    putSetIfNotExsits(lockedParameterNamesScopeMapEntry, info.getParameterName());
                }
            } else {
                putMapIfNotExsits(overrideForceMap, info.getParameterName(), entry.getValue());
                if (info.isLocked()) {
                    putSetIfNotExsits(lockedParameterNamesSet, info.getParameterName());
                }
            }
        } catch (IllegalArgumentException ex) {
            log.warn("Ignoring invalid parameter override definition:\n" + ex.getMessage());
        }
    }
}

From source file:org.jongo.SaveTest.java

@Test
public void shouldFailWhenMarshallerFail() throws Exception {

    try {//from ww w.  ja va  2 s  .  c  om
        collection.save(new ErrorObject());
        Assert.fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage()).contains("Unable to save object");
    }
}

From source file:ste.web.http.velocity.BugFreeVelocityHandler.java

@Test
public void constructors() throws Exception {
    try {//from   w  w w  .j  av  a 2 s  .  c  o m
        new VelocityHandler(null);
        fail("missing check for null parameters");
    } catch (IllegalArgumentException x) {
        then(x.getMessage()).contains("webroot").contains("not be null");
    }

    VelocityHandler h = new VelocityHandler(new File(ROOT).getAbsolutePath());
    then(handler.getViewsFolder()).isEqualTo(DEFAULT_VIEWS_PREFIX);
    then(handler.getEngine()).isNotNull();

    h = new VelocityHandler(new File(ROOT).getAbsolutePath(), "/v");
    then(h.getViewsFolder()).isEqualTo("/v");

    h = new VelocityHandler(new File(ROOT).getAbsolutePath(), null);
    then(h.getViewsFolder()).isEqualTo(DEFAULT_VIEWS_PREFIX);

    h = new VelocityHandler(new File(ROOT).getAbsolutePath(), "/a");
    then(h.getViewsFolder()).isEqualTo("/a");
}