Package com.sun.jersey.api.container

Examples of com.sun.jersey.api.container.MappableContainerException


    }

    @Provider
    public static class MyMappedThrowingExceptionMapper implements ExceptionMapper<MyMappedThrowingException> {
        public Response toResponse(MyMappedThrowingException exception) {
            throw new MappableContainerException(new IOException());
        }
View Full Code Here


        try {
            return bw.readFrom(type, genericType, as, mediaType, headers, entity);
        } catch (WebApplicationException ex) {
            throw ex;
        } catch (Exception e) {
            throw new MappableContainerException(e);
        }
    }
View Full Code Here

        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        try {
            writer.writeTo(entity, type, genericType, annotations, mediaType, httpHeaders, byteArrayOutputStream);
        } catch (IOException e) {
            throw new MappableContainerException(e);
        }

        this.entity = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
    }
View Full Code Here

  @Override
  public Response toResponse(AccessDeniedException e) {

    LOGGER.debug("Spring security threw a "+e.getClass().getName(), e);
    throw new MappableContainerException(e);
  }
View Full Code Here

    private User authenticate(ContainerRequest request) {

        // Extract authentication credentials
        String authentication = request.getHeaderValue(ContainerRequest.AUTHORIZATION);
        if (authentication == null) {
            throw new MappableContainerException
                    (new AuthenticationException("Authentication credentials are required\r\n", REALM));
        }
        if (!authentication.startsWith("Basic ")) {
            throw new MappableContainerException
                    (new AuthenticationException("Only HTTP Basic authentication is supported\r\n", REALM));
        }
        authentication = authentication.substring("Basic ".length());
        String[] values = new String(Base64.base64Decode(authentication)).split(":");
        if (values.length < 2) {
            throw new MappableContainerException
                    (new AuthenticationException("Invalid syntax for username and password\r\n", REALM));
        }
        String username = values[0];
        String password = values[1];
        if ((username == null) || (password == null)) {
            throw new MappableContainerException
                    (new AuthenticationException("Missing username or password\r\n", REALM));
        }

        // Validate the extracted credentials
        User user = null;
        synchronized (Database.users) {
            user = Database.users.get(username);
            if (user == null) {
                throw new MappableContainerException(new AuthenticationException("Invalid username or password\r\n", REALM));
            } else if (!password.trim().equals(user.getPassword().trim())) {
                throw new MappableContainerException(new AuthenticationException("Invalid username or password\r\n", REALM));
            }
        }

        // Return the validated user
        return user;
View Full Code Here

        try {
            return bw.readFrom(type, genericType, as, mediaType, headers, entity);
        } catch (WebApplicationException ex) {
            throw ex;
        } catch (Exception e) {
            throw new MappableContainerException(e);
        }
    }
View Full Code Here

        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        try {
            writer.writeTo(entity, type, genericType, annotations, mediaType, httpHeaders, byteArrayOutputStream);
        } catch (IOException e) {
            throw new MappableContainerException(e);
        }

        this.entity = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
    }
View Full Code Here

                dispatchingListener.onSubResourceLocator(Thread.currentThread().getId(), locator);
                return m.invoke(resource, params);
            }
        } catch (InvocationTargetException e) {
            // Propagate the target exception so it may be mapped to a response
            throw new MappableContainerException(e.getTargetException());
        } catch (IllegalAccessException e) {
            throw new ContainerException(e);
        } catch (WebApplicationException e) {
            throw e;
        } catch (RuntimeException e) {
View Full Code Here

                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InvocationTargetException ex) {
                // Propagate the target exception so it may be mapped to a response
                throw new MappableContainerException(ex.getTargetException());
            } catch (WebApplicationException ex) {
                throw ex;
            } catch (RuntimeException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
View Full Code Here

        }

        try {
            return bw.readFrom(type, genericType, as, mediaType, headers, entity);
        } catch (RuntimeException e) {
            throw new MappableContainerException(e);
        } catch (Exception e) {
            throw new MappableContainerException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.container.MappableContainerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.