@Override public Response deleteServicesNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting the services resource is not allowed."); }
@Override public Response putServicesNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Putting to the services resource is not allowed."); }
@Override public Response postMenuBarsNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to the menuBars resource is not allowed."); }
@Override public Response deleteHealthNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting the health resource is not allowed."); }
@Override public Response postHealthNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to the version resource is not allowed."); }
@Override public Response deleteVersionNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting the version resource is not allowed."); }
@Override public Response putUserNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Putting to the user resource is not allowed."); }
@Override public Response postServicesNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to the services resource is not allowed."); }
@Override public Response deleteHomePageNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting the home page resource is not allowed."); }
@Override public Response postHomePageNotAllowed() { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to the home page resource is not allowed."); }
@Override public Response deleteActionPromptNotAllowed(@PathParam("serviceId") String serviceId, @PathParam("actionId") String actionId) { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting action prompt resource is not allowed."); }
protected void ensureJaxbAnnotated(final Class<?> domainType) { if(domainType.getAnnotation(XmlRootElement.class) == null) { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.BAD_REQUEST, "Requested domain Type '" + domainType.getName() + "' is not annotated with JAXB @XmlRootElement annotation"); } }
@Override public Response postActionPromptNotAllowed(@PathParam("serviceId") String serviceId, @PathParam("actionId") String actionId) { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to an action prompt resource is not allowed."); }
protected void ensureDomainObjectAssignable(final String xRoDomainType, final Class<?> domainType, final Object domainObject) { if(!domainType.isAssignableFrom(domainObject.getClass())) { throw RestfulObjectsApplicationException.createWithMessage( RestfulResponse.HttpStatusCode.NOT_ACCEPTABLE, "Requested object of type '%s' however the object returned by the domain object is not assignable (is '%s')", xRoDomainType, domainObject.getClass().getName()); } }
@Override public Response deleteActionPromptNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") String instanceId, @PathParam("actionId") String actionId) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting action prompt resource is not allowed."); }
private void ensureDomainModelQueryParamSupported() { final DomainModel domainModel = getArg(RequestParameter.DOMAIN_MODEL); if(domainModel != DomainModel.FORMAL) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "x-ro-domain-model of '%s' is not supported", domainModel); } }
protected ObjectAdapter getObjectAdapterElseThrowNotFound(String domainType, final String instanceId) { ObjectAdapter objectAdapter = getObjectAdapterElseNull(domainType, instanceId); if (objectAdapter == null) { final String instanceIdUnencoded = UrlDecoderUtils.urlDecode(instanceId); throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.NOT_FOUND, "could not determine adapter for OID: '%s:%s'", domainType, instanceIdUnencoded); } return objectAdapter; }
protected ObjectAdapter getServiceAdapter(final String serviceId) { final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices(); for (final ObjectAdapter serviceAdapter : serviceAdapters) { final Object servicePojo = serviceAdapter.getObject(); final String id = ServiceUtil.id(servicePojo); if (serviceId.equals(id)) { return serviceAdapter; } } throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.NOT_FOUND, "Could not locate service '%s'", serviceId); }
ObjectAdapter parseAsMapWithSingleValue(final JsonRepresentation arguments) { final JsonRepresentation representation = arguments.getRepresentation("value"); if (arguments.size() != 1 || representation == null) { throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.BAD_REQUEST, "Body should be a map with a single key 'value' whose value represents an instance of type '%s'", resourceFor(objectSpec)); } return objectAdapterFor(arguments); }
private static String linkFromFormalArgs(final String argumentsAsQueryString, final String paramName) { final JsonRepresentation arguments = Util.readQueryStringAsMap(argumentsAsQueryString); if (!arguments.isLink(paramName)) { throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Args should contain a link '%s'", paramName); } return arguments.getLink(paramName).getHref(); }