Package org.restlet.data

Examples of org.restlet.data.Reference


            if (result == RESULT_VALID) {
                if (AuthenticatorUtils.anyNull(nonce, uri)) {
                    result = RESULT_MISSING;
                } else {
                    Reference resourceRef = request.getResourceRef();
                    String requestUri = resourceRef.getPath();

                    if ((resourceRef.getQuery() != null)
                            && (uri.indexOf('?') > -1)) {
                        // IE neglects to include the query string, so
                        // the workaround is to leave it off
                        // unless both the calculated URI and the
                        // specified URI contain a query string
                        requestUri += "?" + resourceRef.getQuery();
                    }

                    if (uri.equals(requestUri)) {
                        char[] a1 = getWrappedSecretDigest(username);
                        if (a1 != null) {
View Full Code Here


     */
    public Source resolve(String href, String base) throws TransformerException {
        Source result = null;

        if (this.context != null) {
            Reference targetRef = null;

            if ((base != null) && !base.equals("")) {
                // Potentially a relative reference
                Reference baseRef = new Reference(base);
                targetRef = new Reference(baseRef, href);
            } else {
                // No base, assume "href" is an absolute URI
                targetRef = new Reference(href);
            }

            String targetUri = targetRef.getTargetRef().toString();
            Response response = this.context.getClientDispatcher().handle(
                    new Request(Method.GET, targetUri));
View Full Code Here

        final Person newPerson = new Person("Kurt", "Beck");
        final Response response1 = post(new JaxbRepresentation<Person>(
                newPerson));
        sysOutEntityIfError(response1);
        assertEquals(Status.SUCCESS_CREATED, response1.getStatus());
        final Reference newLocation = response1.getLocationRef();

        final Response response2 = get(newLocation, MediaType.TEXT_XML);
        sysOutEntityIfError(response2);
        assertEquals(Status.SUCCESS_OK, response2.getStatus());
        final JaxbRepresentation<Person> repr = new JaxbRepresentation<Person>(
View Full Code Here

        if (peek() != -1) {
            result = new ContactInfo();
            if (peek() == '"') {
                result.setDisplayName(readQuotedString());
                skipSpaces();
                result.setReference(new Reference(readReference()));
            } else if (peek() == '<') {
                result.setReference(new Reference(readReference()));
            } else if (HeaderUtils.isTokenChar(peek())) {
                // Read value until end or value or parameter separator
                StringBuilder sb = null;
                int next = read();

                while ((next != -1) && !isComma(next) && !isSemiColon(next)) {
                    if (sb == null) {
                        sb = new StringBuilder();
                    }

                    sb.append((char) next);
                    next = read();
                }

                // Remove trailing spaces
                if (sb != null) {
                    for (int i = sb.length() - 1; (i >= 0)
                            && isLinearWhiteSpace(sb.charAt(i)); i--) {
                        sb.deleteCharAt(i);
                    }
                }

                // Unread the separator
                if (isComma(next) || isSemiColon(next)) {
                    unread();
                }

                // The last token is the reference
                int index = sb.lastIndexOf(" ");
                if (index != -1) {
                    if (sb.charAt(index + 1) == '<') {
                        if (sb.charAt(sb.length() - 1) == '>') {
                            result.setReference(new Reference(sb.substring(
                                    index + 2, sb.length() - 1)));
                        } else {
                            throw new IOException(
                                    "Unexpected end of reference. Please check your value");
                        }
                    }
                    result.setDisplayName(sb.substring(0, index).trim());
                } else {
                    result.setReference(new Reference(sb.toString()));
                }
            }
        }

        // Read address parameters.
View Full Code Here

    @Override
    public ClientCall create(Request request) {
        ClientCall result = null;

        try {
            Reference targetRef = request.getResourceRef().getBaseRef() == null ? request
                    .getResourceRef() : request.getResourceRef().getTargetRef();
            ChallengeResponse cr = request.getProxyChallengeResponse();

            if (cr != null) {
                if (cr.getScheme().equals(ChallengeScheme.valueOf("SDC"))) {
                    String key = cr.getIdentifier() + ":"
                            + String.valueOf(cr.getSecret());
                    int retryAttempts = 3;
                    int retryDelay = 3000;
                    SdcServerConnection ssc = null;

                    for (int i = 0; (ssc == null) && (i < retryAttempts); i++) {
                        ssc = getConnections().get(key);

                        if (ssc == null) {
                            try {
                                Thread.sleep(retryDelay);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }

                    if (ssc == null) {
                        getLogger()
                                .log(Level.WARNING,
                                        "Unable to find an established SDC tunnel for this request: ",
                                        request.getResourceRef());
                    } else {
                        result = new SdcClientCall(this, ssc, request
                                .getMethod().toString(), targetRef.toString());
                    }
                }
            }
        } catch (IOException ioe) {
            getLogger().log(Level.WARNING,
View Full Code Here

    private static final UriInfo createUriInfo2() {
        return newUriInfo(REFERENCE_2, BASE_REF);
    };

    private static final ThreadLocalizedUriInfo createUriInfo5() {
        return newUriInfo(new Reference(BASE_REF, BASE_REF_STR
                + "hfk;abc=%20def;ghi=jkl"), BASE_REF);
    };
View Full Code Here

        return newUriInfo(new Reference(BASE_REF, BASE_REF_STR
                + "hfk;abc=%20def;ghi=jkl"), BASE_REF);
    };

    private static final ThreadLocalizedUriInfo createUriInfo7() {
        return newUriInfo(new Reference(BASE_REF, BASE_REF_STR
                + "abc?def=123&ghi=456"), BASE_REF);
    };
View Full Code Here

        return newUriInfo(new Reference(BASE_REF, BASE_REF_STR
                + "abc?def=123&ghi=456"), BASE_REF);
    };

    private static final ThreadLocalizedUriInfo createUriInfo8() {
        return newUriInfo(new Reference(BASE_REF, BASE_REF_STR
                + "abc?def=1+23&gh%20i=45%206"), BASE_REF);
    }
View Full Code Here

        checkPathSegments(createUriInfo2().getPathSegments(true), "relativ", 0,
                " a ", 0, "!b@,", 0);
        checkPathSegments(createUriInfo2().getPathSegments(false), "relativ",
                0, "%20a%20", 0, "%21b%40%2C", 0);

        final UriInfo uriInfo = newUriInfo(new Reference(BASE_REF, BASE_REF_STR
                + "abc/def;ghi=jkl;mno=pqr/stu;vwx=yz"), BASE_REF);
        final List<PathSegment> pathSegments = uriInfo.getPathSegments();
        checkPathSegments(pathSegments, "abc", 0, "def", 2, "stu", 1);

        final MultivaluedMap<String, String> templateParameters1 = pathSegments
View Full Code Here

     *            without beginning '/'
     * @return
     */
    private Reference createReference2(String subPath) {
        final String baseRef = createBaseRef() + "/pathParamTest/" + subPath;
        return new Reference(createBaseRef(), baseRef);
    }
View Full Code Here

TOP

Related Classes of org.restlet.data.Reference

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.