Package org.restlet.data

Examples of org.restlet.data.LocalReference


        // Ensure that all ".." and "." are normalized into the path
        // to preven unauthorized access to user directories.
        request.getResourceRef().normalize();

        if (scheme.equalsIgnoreCase(Protocol.CLAP.getSchemeName())) {
            LocalReference cr = new LocalReference(request.getResourceRef());

            if (cr.getClapAuthorityType() == LocalReference.CLAP_CLASS) {
                handleClassLoader(request, response, getClass()
                        .getClassLoader());
            } else if (cr.getClapAuthorityType() == LocalReference.CLAP_SYSTEM) {
                handleClassLoader(request, response, ClassLoader
                        .getSystemClassLoader());
            } else if (cr.getClapAuthorityType() == LocalReference.CLAP_THREAD) {
                handleClassLoader(request, response, Thread.currentThread()
                        .getContextClassLoader());
            }
        } else {
            throw new IllegalArgumentException(
View Full Code Here


     *            system format or in 'file:///' format).
     * @return The associated File instance.
     */
    private static File createFile(String path) {
        if (path.startsWith("file://")) {
            return new LocalReference(path).getFile();
        }

        return new File(path);
    }
View Full Code Here

    public void handle(Request request, Response response) {
        final String scheme = request.getResourceRef().getScheme();

        if (Protocol.RIAP.getSchemeName().equalsIgnoreCase(scheme)) {
            // Support only the "component" authority
            LocalReference ref = new LocalReference(request.getResourceRef());
            if (ref.getRiapAuthorityType() == LocalReference.RIAP_COMPONENT) {
                if (RiapServerHelper.instance != null
                        && RiapServerHelper.instance.getContext() != null
                        && RiapServerHelper.instance.getContext()
                                .getClientDispatcher() != null) {
                    RiapServerHelper.instance.getContext()
                            .getClientDispatcher().handle(request, response);
                } else {
                    super.handle(request, response);
                }
            } else {
                throw new IllegalArgumentException(
                        "Authority \""
                                + ref.getAuthority()
                                + "\" not supported by the connector. Only \"component\" is supported.");
            }
        } else {
            throw new IllegalArgumentException(
                    "Protocol \""
View Full Code Here

    protected void handleLocal(Request request, Response response,
            String decodedPath) {
        String scheme = request.getResourceRef().getScheme();

        if (scheme.equalsIgnoreCase(Protocol.CLAP.getSchemeName())) {
            LocalReference cr = new LocalReference(request.getResourceRef());
            ClassLoader classLoader = null;

            if ((cr.getClapAuthorityType() == LocalReference.CLAP_CLASS)
                    || (cr.getClapAuthorityType() == LocalReference.CLAP_DEFAULT)) {
                // Sometimes, a specific class loader needs to be used,
                // make sure that it can be provided as a request's attribute
                Object classLoaderAttribute = request.getAttributes().get(
                        "org.restlet.clap.classLoader");

                if (classLoaderAttribute != null) {
                    classLoader = (ClassLoader) classLoaderAttribute;
                } else {
                    // Old name to be deprecated
                    classLoaderAttribute = request.getAttributes().get(
                            "org.restlet.clap.classloader");

                    if (classLoaderAttribute != null) {
                        classLoader = (ClassLoader) classLoaderAttribute;
                    } else {
                        classLoader = getClass().getClassLoader();
                    }
                }
            } else if (cr.getClapAuthorityType() == LocalReference.CLAP_SYSTEM) {
                classLoader = ClassLoader.getSystemClassLoader();
            } else if (cr.getClapAuthorityType() == LocalReference.CLAP_THREAD) {
                classLoader = Thread.currentThread().getContextClassLoader();
            }

            handleClassLoader(request, response, classLoader);
        } else {
View Full Code Here

        super.doHandle(request, response);
        Protocol protocol = request.getProtocol();

        if (protocol.equals(Protocol.RIAP)) {
            // Let's dispatch it
            final LocalReference cr = new LocalReference(request
                    .getResourceRef());
            final Component component = getComponent();

            if (component != null) {
                if (cr.getRiapAuthorityType() == LocalReference.RIAP_COMPONENT) {
                    // This causes the baseRef of the resource reference to be
                    // set as if it had actually arrived from a server
                    // connector.
                    request.getResourceRef().setBaseRef(
                            request.getResourceRef().getHostIdentifier());

                    // Ask the private internal route to handle the call
                    component.getInternalRouter().handle(request, response);
                } else if (cr.getRiapAuthorityType() == LocalReference.RIAP_HOST) {
                    VirtualHost host = null;
                    VirtualHost currentHost = null;
                    final Integer hostHashCode = VirtualHost.getCurrent();

                    // Lookup the virtual host
View Full Code Here

        } else {
            fileUri = decodedPath;
            entryName = "";
        }

        LocalReference fileRef = new LocalReference(fileUri);
        if (Protocol.FILE.equals(fileRef.getSchemeProtocol())) {
            final File file = fileRef.getFile();
            if (Method.GET.equals(request.getMethod())
                    || Method.HEAD.equals(request.getMethod())) {
                handleGet(request, response, file, entryName,
                        getMetadataService());
            } else if (Method.PUT.equals(request.getMethod())) {
View Full Code Here

        super.doHandle(request, response);
        final Protocol protocol = request.getProtocol();

        if (protocol.equals(Protocol.RIAP)) {
            // Let's dispatch it
            final LocalReference cr = new LocalReference(request
                    .getResourceRef());

            if (cr.getRiapAuthorityType() == LocalReference.RIAP_APPLICATION) {
                if ((getChildContext() != null)
                        && (getChildContext().getChild() instanceof Application)) {
                    Application application = (Application) getChildContext()
                            .getChild();
                    request.getResourceRef().setBaseRef(
                            request.getResourceRef().getHostIdentifier());
                    application.getInboundRoot().handle(request, response);
                }
            } else if (cr.getRiapAuthorityType() == LocalReference.RIAP_COMPONENT) {
                parentHandle(request, response);
            } else if (cr.getRiapAuthorityType() == LocalReference.RIAP_HOST) {
                parentHandle(request, response);
            } else {
                getLogger()
                        .warning(
                                "Unknown RIAP authority. Only \"component\", \"host\" and \"application\" are supported.");
View Full Code Here

                        } else if (remainder.equals("/null")) {
                            result = new ObjectRepresentation<Serializable>(
                                    (Serializable) null);
                        } else if (remainder.equals("/self-aggregated")) {
                            final String echoMessage = ECHO_TEST_MSG;
                            final Reference echoRef = new LocalReference(
                                    selfBase + "/echo/" + echoMessage);
                            String echoCopy = null;
                            try {
                                ClientResource r = new ClientResource(echoRef);
                                echoCopy = r.get().getText();
View Full Code Here

*/
public class FileReferenceTestCase extends RestletTestCase {

    public void testCreation() {
        String path = "D:\\Restlet\\build.xml";
        LocalReference fr = LocalReference.createFileReference(path);
        fr.getFile();

        assertEquals("file", fr.getScheme());
        assertEquals("", fr.getAuthority());

        if (File.separatorChar == '\\') {
            assertEquals("/D%3A/Restlet/build.xml", fr.getPath());
        } else {
            assertEquals("/D%3A%5CRestlet%5Cbuild.xml", fr.getPath());
        }
    }
View Full Code Here

        // xml In
        Representation xmlIn = new StringRepresentation(
                "<?xml version='1.0' ?><input><one/><any attTwo='2'/><el3>drie</el3></input>");
        // xslOne
        Reference xsltOneRef = new LocalReference("clap://thread/"
                + MY_BASEPATH + "/xslt/one/1st.xsl");
        Representation xsltOne = comp.getContext().getClientDispatcher()
                .handle(new Request(Method.GET, xsltOneRef)).getEntity();
        TransformRepresentation tr = new TransformRepresentation(comp
                .getContext(), xmlIn, xsltOne);
View Full Code Here

TOP

Related Classes of org.restlet.data.LocalReference

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.