/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.rest.resources;

import org.restlet.resource.Representation;
import org.restlet.resource.Variant;
import org.xwiki.rest.DomainObjectFactory;
import org.xwiki.rest.XWikiResource;
import org.xwiki.rest.model.XWikiRoot;

/**
 * @version $Id$
 */
public class RootResource extends XWikiResource
{
    @Override
    public Representation represent(Variant variant)
    {
        XWikiRoot xwikiRoot = DomainObjectFactory.createXWikiRoot(getRequest(), xwikiApi, resourceClassRegistry);

        return getRepresenterFor(variant).represent(getContext(), getRequest(), getResponse(), xwikiRoot);
    }
}

/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.rest.resources;

import org.restlet.data.MediaType;
import org.restlet.resource.Representation;
import org.restlet.resource.Variant;
import org.xwiki.rest.DomainObjectFactory;
import org.xwiki.rest.XWikiRestApplication;
import org.xwiki.rest.XWikiResource;
import org.xwiki.rest.model.XWikiRoot;

/**
 * @version $Id$
 */
public class RootResource extends XWikiResource
{
    @Override
    public Representation represent(Variant variant)
    {
        XWikiRoot xwikiRoot = DomainObjectFactory.createXWikiRoot(getRequest(), xwikiApi, resourceClassRegistry);

        return getRepresenterFor(variant).represent(getContext(), getRequest(), getResponse(), xwikiRoot);
    }

    /* Mimic the behavior of a OPTION request to the root of a WADL application in RESTlet */
    @Override
    public boolean allowOptions()
    {
        return true;
    }

    @Override
    public void handleOptions()
    {
        if (isAutoDescribed()) {
            XWikiRestApplication application = (XWikiRestApplication) getApplication();
            getResponse().setEntity(
                application.wadlRepresent(new Variant(MediaType.APPLICATION_WADL_XML), getRequest(), getResponse()));
        }
    }
}

Develop the initial feature set of the REST API