package de.mpiwg.itgroup.annotations.restlet; /* * #%L * AnnotationManager * %% * Copyright (C) 2012 - 2014 MPIWG Berlin * %% * This program 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 3 of the * License, or (at your option) any later version. * * This program 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 General Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ import java.util.Arrays; import java.util.HashSet; import org.restlet.Restlet; import org.restlet.engine.application.CorsFilter; import org.restlet.routing.Router; import de.mpiwg.itgroup.annotations.restlet.utils.UrlPrefixFilter; /** * @author casties * */ public class AnnotatorRestlet extends BaseRestlet { public final String version = "AnnotationManagerN4J/Annotator 0.5.2"; /* * (non-Javadoc) * * @see org.restlet.Application#createInboundRoot() */ @Override public Restlet createInboundRoot() { Restlet root = null; Router router = new Router(getContext()); router.attach("/annotations", AnnotatorAnnotations.class); router.attach("/annotations/{id}", AnnotatorAnnotations.class); router.attach("/search", AnnotatorSearch.class); router.attach("/groups", AnnotatorGroups.class); router.attach("/tags", AnnotatorTags.class); router.attach("/tags/{id}", AnnotatorTags.class); router.attach("/tags/{id}/annotations", AnnotatorAnnotationsByTags.class); router.attach("/resources", AnnotatorResources.class); router.attach("/resources/{id}", AnnotatorResources.class); router.attach("/resources/{id}/annotations", AnnotatorAnnotationsByResources.class); router.attach("/", AnnotatorInfo.class); root = router; // this.authenticator = createAuthenticator(); // authenticator.setNext(router); if (this.webappUriPrefix != null) { // add prefix path to url UrlPrefixFilter prefixFilter = new UrlPrefixFilter(); prefixFilter.setPrefix(this.webappUriPrefix);; prefixFilter.setNext(root); root = prefixFilter; } // handle Cross-Origin-Resource-Security headers CorsFilter corsFilter = new CorsFilter(getContext(), router); corsFilter.setAllowedOrigins(new HashSet(Arrays.asList("*"))); corsFilter.setAllowedCredentials(true); corsFilter.setNext(root); root = corsFilter; return root; } /* (non-Javadoc) * @see de.mpiwg.itgroup.annotations.restlet.RestletImpl#getVersion() */ @Override public String getVersion() { return version; } }