Example usage for java.lang UnsupportedOperationException getMessage

List of usage examples for java.lang UnsupportedOperationException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.hawq.pxf.plugins.hive.HiveMetadataFetcherTest.java

@Test
public void getTableMetadataView() throws Exception {
    prepareConstruction();/*from  w  ww . j a v  a  2  s  .  c o  m*/

    fetcher = new HiveMetadataFetcher();
    String tableName = "cause";

    // mock hive table returned from hive client
    Table hiveTable = new Table();
    hiveTable.setTableType("VIRTUAL_VIEW");
    when(hiveClient.getTable("default", tableName)).thenReturn(hiveTable);

    try {
        metadata = fetcher.getTableMetadata(tableName);
        fail("Expected an UnsupportedOperationException because PXF doesn't support views");
    } catch (UnsupportedOperationException e) {
        assertEquals("Hive views are not supported by HAWQ", e.getMessage());
    }
}

From source file:bear.plugins.Plugin.java

public boolean isConsoleSupported() {
    try {/* www.j  av  a2s.co m*/
        getConsole();
        return true;
    } catch (UnsupportedOperationException e) {
        return !e.getMessage().contains("plugin does not support console");
    }
}

From source file:org.xdi.oxauth.client.FederationDataClient.java

private FederationDataResponse exec(FederationDataRequest p_request) {
    setResponse(new FederationDataResponse());
    final String httpMethod = getHttpMethod();

    initClientRequest();//from  w  w w  .j a v  a  2  s. c om
    clientRequest.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
    clientRequest.setHttpMethod(httpMethod);

    try {
        if (HttpMethod.POST.equals(httpMethod)) {
            putAllFormParameters(clientRequest, p_request);

            clientResponse = clientRequest.post(String.class);

            setRequest(p_request);

            final String entity = clientResponse.getEntity(String.class);

            getResponse().setStatus(clientResponse.getStatus());
            getResponse().setHeaders(clientResponse.getHeaders());
            getResponse().setLocation(
                    clientResponse.getLocation() != null ? clientResponse.getLocation().getHref() : "");
            getResponse().setEntity(entity);

            if (StringUtils.isNotBlank(entity)) {
                getResponse().injectErrorIfExistSilently(entity);
            }
        } else {
            LOG.error("HTTP method is not supported. Method:" + httpMethod);
            throw new UnsupportedOperationException("HTTP method is not supported. Method:" + httpMethod);
        }
    } catch (UnsupportedOperationException e) {
        throw e;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    } finally {
        closeConnection();
    }

    return getResponse();
}

From source file:com.orange.ngsi2.exception.UnsupportedOperationExceptionTest.java

@Test
public void checkProperties() {
    UnsupportedOperationException exception = new UnsupportedOperationException("List Entities");
    assertEquals(//from  w w w .  j a va 2 s .c  om
            "error: 501 | description: this operation 'List Entities' is not implemented | affectedItems: []",
            exception.getMessage());
}

From source file:org.musicrecital.webapp.pages.Login.java

@SuppressWarnings("unchecked")
public boolean isRememberMeEnabled() {
    try {//from w w  w . j  a  va2s  .  c  o m
        Map config = (HashMap) context.getAttribute(Constants.CONFIG);
        if (config != null) {
            return (config.get("rememberMeEnabled") != null);
        }
    } catch (UnsupportedOperationException uoe) {
        // only happens in tests
        // getAttribute() is not supported for ContextForPageTester
        logger.warn(uoe.getMessage());
    }
    return false;
}

From source file:org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration.java

private CookieSerializer createDefaultCookieSerializer() {
    DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
    if (this.servletContext != null) {
        SessionCookieConfig sessionCookieConfig = null;
        try {/*from  w  w w. j  a  v a  2 s  . co m*/
            sessionCookieConfig = this.servletContext.getSessionCookieConfig();
        } catch (UnsupportedOperationException ex) {
            this.logger.warn("Unable to obtain SessionCookieConfig: " + ex.getMessage());
        }
        if (sessionCookieConfig != null) {
            if (sessionCookieConfig.getName() != null) {
                cookieSerializer.setCookieName(sessionCookieConfig.getName());
            }
            if (sessionCookieConfig.getDomain() != null) {
                cookieSerializer.setDomainName(sessionCookieConfig.getDomain());
            }
            if (sessionCookieConfig.getPath() != null) {
                cookieSerializer.setCookiePath(sessionCookieConfig.getPath());
            }
            if (sessionCookieConfig.getMaxAge() != -1) {
                cookieSerializer.setCookieMaxAge(sessionCookieConfig.getMaxAge());
            }
        }
    }
    if (this.usesSpringSessionRememberMeServices) {
        cookieSerializer.setRememberMeRequestAttribute(SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR);
    }
    return cookieSerializer;
}

From source file:org.apache.ddlutils.task.DropDatabaseCommand.java

/**
 * {@inheritDoc}//w w  w. ja v a 2s .  c om
 */
public void execute(DatabaseTaskBase task, Database model) throws BuildException {
    BasicDataSource dataSource = getDataSource();

    if (dataSource == null) {
        throw new BuildException("No database specified.");
    }

    Platform platform = getPlatform();

    try {
        platform.dropDatabase(dataSource.getDriverClassName(), dataSource.getUrl(), dataSource.getUsername(),
                dataSource.getPassword());

        _log.info("Dropped database");
    } catch (UnsupportedOperationException ex) {
        _log.error("Database platform " + platform.getName() + " does not support database dropping via JDBC",
                ex);
    } catch (Exception ex) {
        handleException(ex, ex.getMessage());
    }
}

From source file:fr.paris.lutece.plugins.rest.service.LuteceJerseySpringServlet.java

/**
 *
 * Initialize the services. Adds suffix to mediatype mapping.
 * @param rc ResourceConfig//from  w  w w  .  j a v a 2 s  .c  o  m
 * @param wa WebApplication
 * @see com.sun.jersey.api.container.filter.UriConnegFilter
 */
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
    try {
        try {
            // map default ".extension" to MediaType
            rc.getMediaTypeMappings().put("atom", MediaType.APPLICATION_ATOM_XML_TYPE);
            rc.getMediaTypeMappings().put("xml", MediaType.APPLICATION_XML_TYPE);
            rc.getMediaTypeMappings().put("json", MediaType.APPLICATION_JSON_TYPE);
            rc.getMediaTypeMappings().put("kml", RestMediaTypes.APPLICATION_KML_TYPE);

            // add specific-plugin-provided extensions
            List<MediaTypeMapping> listMappings = SpringContextService.getBeansOfType(MediaTypeMapping.class);

            if (listMappings != null) {
                for (MediaTypeMapping mapping : listMappings) {
                    String strExtension = mapping.getExtension();
                    MediaType mediaType = mapping.getMediaType();

                    if (StringUtils.isNotBlank(strExtension) && (mediaType != null)) {
                        rc.getMediaTypeMappings().put(strExtension, mediaType);
                    } else {
                        LOGGER.error("Can't add media type mapping for extension : " + strExtension
                                + ", mediatype : " + mediaType + ". Please check your context configuration.");
                    }
                }
            }
        } catch (UnsupportedOperationException uoe) {
            // might be immutable map
            LOGGER.error(uoe.getMessage() + ". Won't support extension mapping (.json, .xml, .atom)", uoe);
        }

        wa.initiate(rc, new SpringComponentProviderFactory(rc, getContext()));

        // log services
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Listing registered services and providers");

            for (Class<?> clazz : rc.getClasses()) {
                LOGGER.debug(clazz);
            }

            LOGGER.debug("End of listing");
        }
    } catch (RuntimeException e) {
        LOGGER.log(Level.ERROR,
                "REST services won't be available. Please check your configuration or enable at least on rest module.");
        LOGGER.log(Level.ERROR, "LuteceJerseySpringServlet : Exception occurred when intialization", e);
        // throw e;
    }
}

From source file:org.apache.fop.render.pcl.PCLGraphics2DAdapter.java

/** {@inheritDoc} */
public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width,
        int height) throws IOException {
    PCLRendererContext pclContext = PCLRendererContext.wrapRendererContext(context);
    PCLRenderer pcl = (PCLRenderer) context.getRenderer();
    PCLGenerator gen = pcl.gen;/*from w w  w  .j  a  va 2s  .  c om*/

    // get the 'width' and 'height' attributes of the image/document
    Dimension dim = painter.getImageSize();
    float imw = (float) dim.getWidth();
    float imh = (float) dim.getHeight();

    boolean painted = false;
    boolean paintAsBitmap = pclContext.paintAsBitmap();
    if (!paintAsBitmap) {
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        PCLGenerator tempGen = new PCLGenerator(baout, gen.getMaximumBitmapResolution());
        try {
            GraphicContext ctx = (GraphicContext) pcl.getGraphicContext().clone();

            AffineTransform prepareHPGL2 = new AffineTransform();
            prepareHPGL2.scale(0.001, 0.001);
            ctx.setTransform(prepareHPGL2);

            PCLGraphics2D graphics = new PCLGraphics2D(tempGen);
            graphics.setGraphicContext(ctx);
            graphics.setClippingDisabled(pclContext.isClippingDisabled());
            Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
            painter.paint(graphics, area);

            //If we arrive here, the graphic is natively paintable, so write the graphic
            pcl.saveGraphicsState();
            pcl.setCursorPos(x, y);
            gen.writeCommand(
                    "*c" + gen.formatDouble4(width / 100f) + "x" + gen.formatDouble4(height / 100f) + "Y");
            gen.writeCommand("*c0T");
            gen.enterHPGL2Mode(false);
            gen.writeText("\nIN;");
            gen.writeText("SP1;");
            //One Plotter unit is 0.025mm!
            double scale = imw / UnitConv.mm2pt(imw * 0.025);
            gen.writeText("SC0," + gen.formatDouble4(scale) + ",0,-" + gen.formatDouble4(scale) + ",2;");
            gen.writeText("IR0,100,0,100;");
            gen.writeText("PU;PA0,0;\n");
            baout.writeTo(gen.getOutputStream()); //Buffer is written to output stream
            gen.writeText("\n");

            gen.enterPCLMode(false);
            pcl.restoreGraphicsState();
            painted = true;
        } catch (UnsupportedOperationException uoe) {
            log.debug("Cannot paint graphic natively. Falling back to bitmap painting. Reason: "
                    + uoe.getMessage());
        }
    }

    if (!painted) {
        //Fallback solution: Paint to a BufferedImage
        int resolution = Math.round(context.getUserAgent().getTargetResolution());
        BufferedImage bi = paintToBufferedImage(painter, pclContext, resolution, !pclContext.isColorCanvas(),
                false);

        pcl.setCursorPos(x, y);
        gen.paintBitmap(bi, new Dimension(width, height), pclContext.isSourceTransparency());
    }
}

From source file:com.github.jakubkolar.autobuilder.impl.ResolverChain.java

@Nullable
@Override//from   w  w  w  . j  av  a  2s  .co  m
public <T> T resolve(Class<T> type, Optional<Type> typeInfo, String name, Collection<Annotation> annotations) {
    StringBuilder failedResolvers = new StringBuilder();
    for (ValueResolver resolver : resolvers) {
        try {
            return resolver.resolve(type, typeInfo, name, annotations);
        } catch (UnsupportedOperationException e) {
            // TODO: it is probably better if the messages are just logged as a debug output
            failedResolvers.append('\t').append(resolver.getClass().getSimpleName()).append(": ")
                    .append(e.getMessage()).append(SystemUtils.LINE_SEPARATOR);
            // Try next resolver
        }
    }

    throw new UnsupportedOperationException(
            "No suitable resolver found: " + SystemUtils.LINE_SEPARATOR + failedResolvers);
}