Package org.restlet.data

Examples of org.restlet.data.Parameter


     *
     * @return The new message header or null.
     * @throws IOException
     */
    protected Parameter readHeader() throws IOException {
        Parameter header = HeaderReader.readHeader(getLineBuilder());
        clearLineBuilder();
        return header;
    }
View Full Code Here


     * @param name
     *            The parameter name.
     * @return The first parameter found with the given name.
     */
    protected Parameter getParameter(String name) {
        Parameter result = null;
        Series<Parameter> set = getParameters(name);

        if (set != null) {
            result = set.getFirst(name);
        }
View Full Code Here

                addHeaders(getHeaders());
            }

            if (getHeaderIndex() < getHeaders().size()) {
                // Write header
                Parameter header = getHeaders().get(getHeaderIndex());
                getLineBuilder().append(header.getName());
                getLineBuilder().append(": ");
                getLineBuilder().append(header.getValue());
                getLineBuilder().append('\r'); // CR
                getLineBuilder().append('\n'); // LF

                // Move to the next header
                setHeaderIndex(getHeaderIndex() + 1);
View Full Code Here

        Query<T> result = new Query<T>(this.getService(), this.getSubpath(),
                (Class<T>) this.entityClass);
        StringBuilder builder = new StringBuilder();
        if (params != null) {
            for (int i = 0; i < params.size(); i++) {
                Parameter param = params.get(i);
                if (i == 0) {
                    builder.append(param.getName());
                    builder.append("=");
                    builder.append(param.getValue());
                }
            }
        }
        if (getQuery() == null || "".equals(getQuery())) {
            result.setQuery(builder.toString());
View Full Code Here

                }
                result.setName(sb.toString());

                // Read address parameters.
                if (skipParameterSeparator()) {
                    Parameter param = readParameter();

                    while (param != null) {
                        result.getParameters().add(param);

                        if (skipParameterSeparator()) {
View Full Code Here

            }
        }

        // Read address parameters.
        if (skipParameterSeparator()) {
            Parameter param = readParameter();

            while (param != null) {
                result.getParameters().add(param);

                if (skipParameterSeparator()) {
View Full Code Here

            new Function<PropertyDescriptor, Object>()
        {
            @Override
            public Object map( PropertyDescriptor propertyDescriptor )
            {
                Parameter param = queryAsForm.getFirst( propertyDescriptor.qualifiedName().name() );

                if( param == null )
                {
                    param = entityAsForm.getFirst( propertyDescriptor.qualifiedName().name() );
                }

                if( param != null )
                {
                    String value = param.getValue();
                    if( value != null )
                    {
                        try
                        {
                            return valueDeserializer.deserialize( propertyDescriptor.valueType(), value );
                        }
                        catch( ValueSerializationException e )
                        {
                            throw new IllegalArgumentException( "Query parameter has invalid JSON format", e );
                        }
                    }
                }

                return null;
            }
            },
            new Function<AssociationDescriptor, EntityReference>()
            {
                @Override
                public EntityReference map( AssociationDescriptor associationDescriptor )
                {
                    Parameter param = queryAsForm.getFirst( associationDescriptor.qualifiedName().name() );

                    if( param == null )
                    {
                        param = entityAsForm.getFirst( associationDescriptor.qualifiedName().name() );
                    }

                    if( param != null )
                    {
                        return EntityReference.parseEntityReference( param.getValue() );
                    }
                    else
                    {
                        return null;
                    }
View Full Code Here

      assertThat(response.getStatus().isSuccess(), is(true));

      final Form form = (Form) response.getAttributes().get("org.restlet.http.headers");
      assertThat(form, is(notNullValue()));

      final Parameter xCTOHeader = form.getFirst("X-Content-Type-Options");
      assertThat(xCTOHeader, is(notNullValue()));
      assertThat(xCTOHeader.getValue(), is(equalTo("nosniff")));
    }
    finally {
      RequestFacade.releaseResponse(response);
    }
  }
View Full Code Here

                                      ResourceStore store, ResourceStoreRequest request, StorageItem item,
                                      Throwable t)
      throws IOException, AccessDeniedException, NoSuchResourceStoreException, IllegalOperationException,
             ItemNotFoundException, StorageException, ResourceException
  {
    Parameter describeParameter = req.getResourceRef().getQueryAsForm().getFirst(IS_DESCRIBE_PARAMETER);

    if (StringUtils.isNotEmpty(describeParameter.getValue())) {
      // if item is null throw not found
      String key = describeParameter.getValue();

      // check
      if (!viewProviders.containsKey(key)) {
        throw new IllegalRequestException(request, "No view for key: " + key);
      }
View Full Code Here

    // test that for tokenC an custom header is added to response
    assertEquals("tokenC", client.request("http://localhost:8182/tokenC"));
    final Response lastResponse = client.getLastResponse();
    final Form form = (Form) lastResponse.getAttributes().get("org.restlet.http.headers");
    assertNotNull(form);
    final Parameter xCustomHeader = form.getFirst("X-Custom");
    assertNotNull(xCustomHeader);
    assertEquals("foo", xCustomHeader.getValue());
  }
View Full Code Here

TOP

Related Classes of org.restlet.data.Parameter

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.