Package org.restlet.resource

Examples of org.restlet.resource.ResourceException


    String paramValue = queryParams.getFirstValue(paramName);
    try {
      return Protocol.decodeResource(paramValue, vf);
    }
    catch (IllegalArgumentException e) {
      throw new ResourceException(CLIENT_ERROR_BAD_REQUEST, "Invalid value for parameter '" + paramName
          + "': " + paramValue);
    }
  }
View Full Code Here


    String paramValue = queryParams.getFirstValue(paramName);
    try {
      return Protocol.decodeURI(paramValue, vf);
    }
    catch (IllegalArgumentException e) {
      throw new ResourceException(CLIENT_ERROR_BAD_REQUEST, "Invalid value for parameter '" + paramName
          + "': " + paramValue);
    }
  }
View Full Code Here

    String[] paramValues = queryParams.getValuesArray(paramName);
    try {
      return Protocol.decodeContexts(paramValues, vf);
    }
    catch (IllegalArgumentException e) {
      throw new ResourceException(CLIENT_ERROR_BAD_REQUEST, "Invalid value for parameter '" + paramName
          + "': " + e.getMessage());
    }
  }
View Full Code Here

    try {
      return Integer.parseInt(paramValue);
    }
    catch (NumberFormatException e) {
      throw new ResourceException(CLIENT_ERROR_BAD_REQUEST, "Invalid value for parameter '" + paramName
          + "': " + e.getMessage());
    }
  }
View Full Code Here

    try {
      String namespace = getConnection().getNamespace(prefix);

      if (namespace == null) {
        throw new ResourceException(CLIENT_ERROR_NOT_FOUND, "Undefined prefix: " + prefix);
      }

      if (variant.getMediaType().equals(MediaType.TEXT_PLAIN, true)) {
        return new StringRepresentation(namespace);
      }

      throw new ResourceException(SERVER_ERROR_INTERNAL, "Unsupported media type: "
          + variant.getMediaType());
    }
    catch (StoreException e) {
      throw new ResourceException(e);
    }
  }
View Full Code Here

    if (MediaType.TEXT_PLAIN.equals(entity.getMediaType(), true)) {
      try {
        String namespace = entity.getText().trim();

        if (namespace.length() == 0) {
          throw new ResourceException(CLIENT_ERROR_BAD_REQUEST,
              "No namespace name found in request body");
        }
        // FIXME: perform some sanity checks on the namespace string

        ServerConnection connection = getConnection();
        connection.setNamespace(prefix, namespace);
        connection.getCacheInfo().processUpdate();

        getResponse().setStatus(SUCCESS_NO_CONTENT);
        return null;
      }
      catch (IOException e) {
        throw new ResourceException(e);
      }
      catch (StoreException e) {
        throw new ResourceException(e);
      }
    }
    else {
      throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE);
    }
  }
View Full Code Here

      getResponse().setStatus(SUCCESS_NO_CONTENT);
      return null;
    }
    catch (StoreException e) {
      throw new ResourceException(e);
    }
  }
View Full Code Here

      getConnection().commit();
      getResponse().setStatus(SUCCESS_NO_CONTENT);
      return null;
    }
    catch (StoreException e) {
      throw new ResourceException(SERVER_ERROR_INTERNAL, e);
    }
  }
View Full Code Here

      // Include parameters from request's body
      params = new Form(params);
      params.addAll(req.getEntityAsForm());
    }
    else if (mediaType != null) {
      throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, "Unsupported MIME type: "
          + mediaType.getName());
    }
  }
View Full Code Here

      }

      return new ModelRepresentation(model, factory, mediaType);
    }
    catch (Exception e) {
      throw new ResourceException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.restlet.resource.ResourceException

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.