001/**
002 * Copyright (C) 2014  Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
003 *
004 * This file is part of Dicoogle/dicoogle.
005 *
006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Dicoogle/dicoogle is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with Dicoogle.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package pt.ua.dicoogle.server;
020
021import org.slf4j.LoggerFactory;
022import org.restlet.Application;
023import org.restlet.Restlet;
024import org.restlet.routing.Router;
025import pt.ua.dicoogle.server.web.rest.ExamTimeResource;
026import pt.ua.dicoogle.server.web.rest.ForceIndexing;
027import pt.ua.dicoogle.server.web.rest.RestDcmImageResource;
028import pt.ua.dicoogle.server.web.rest.RestDimResource;
029import pt.ua.dicoogle.server.web.rest.RestDumpResource;
030import pt.ua.dicoogle.server.web.rest.RestFileResource;
031import pt.ua.dicoogle.server.web.rest.RestTagsResource;
032import pt.ua.dicoogle.server.web.rest.RestWADOResource;
033
034/** A Restlet Application for aggregating legacy web services.
035 *
036 * @author psytek
037 * @author Luís A. Bastião Silva <bastiao@ua.pt>
038 * @author Eduardo Pinho <eduardopinho@ua.pt>
039 */
040public class LegacyRestletApplication extends Application {
041
042    private Router internalRouter;
043    
044    public LegacyRestletApplication() {
045        super();
046    }
047    
048    /**
049     * Creates a root Restlet that will receive all incoming calls.
050     * @return a Restlet for the root 
051     */
052    @Override
053    public synchronized Restlet createInboundRoot() {
054        // Create a router Restlet that routes each call to a
055        // new instance of our resources
056        this.internalRouter = new Router(getContext());
057
058        // Define routing to resources
059        this.internalRouter.setDefaultMatchingQuery(false);
060        //internalRouter.attach("/test/{something}", TestResource.class);
061        internalRouter.attach("/dim", RestDimResource.class);//search resource
062        internalRouter.attach("/file", RestFileResource.class);//file download resource
063        internalRouter.attach("/dump", RestDumpResource.class);//dump resource
064        internalRouter.attach("/tags", RestTagsResource.class);//list of avalilable tags resource
065        //router.attach("/image", RestImageResource.class);//jpg image resource
066        //router.attach("/enumField", RestEnumField.class);
067        //router.attach("/countResuls", RestCountQueryResults.class);
068        internalRouter.attach("/wado", RestWADOResource.class);
069        internalRouter.attach("/img", RestDcmImageResource.class);
070        internalRouter.attach("/examTime", ExamTimeResource.class);
071        
072        //Advanced Dicoogle Features
073        internalRouter.attach("/doIndex", ForceIndexing.class);
074
075//        internalRouter.attachDefault(ExtResource.class);
076                
077        LoggerFactory.getLogger(LegacyRestletApplication.class).debug("Legacy service routes: {}",
078                internalRouter.getRoutes());
079        return internalRouter;
080    }
081}