| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| StandardStringResourceTypeResolver | 46 | 3 | 0% | 2 | 0 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.url.internal.standard; | |
| 21 | ||
| 22 | import java.util.Map; | |
| 23 | ||
| 24 | import javax.inject.Inject; | |
| 25 | import javax.inject.Named; | |
| 26 | import javax.inject.Singleton; | |
| 27 | ||
| 28 | import org.xwiki.component.annotation.Component; | |
| 29 | import org.xwiki.resource.CreateResourceTypeException; | |
| 30 | import org.xwiki.resource.ResourceType; | |
| 31 | import org.xwiki.resource.ResourceTypeResolver; | |
| 32 | import org.xwiki.resource.entity.EntityResourceReference; | |
| 33 | ||
| 34 | /** | |
| 35 | * Converts the passed type which has been extracted from the URL as a String into a {@link ResourceType} proper. | |
| 36 | * This allows Resource Types to be common to all URL Schemes and as a consequence it allows Resource Reference | |
| 37 | * Resolvers to be registered for all URL Schemes (for those who wish to do this, for example the WebJars one is doing | |
| 38 | * this), since the Resolver is looked up based on the Resource Type id in general. | |
| 39 | * | |
| 40 | * @version $Id: ce09bfec64149f092552f825188e8d6ab774f26f $ | |
| 41 | * @since 7.1M1 | |
| 42 | */ | |
| 43 | @Component | |
| 44 | @Named("standard") | |
| 45 | @Singleton | |
| 46 | public class StandardStringResourceTypeResolver implements ResourceTypeResolver<String> | |
| 47 | { | |
| 48 | @Inject | |
| 49 | private StandardURLConfiguration configuration; | |
| 50 | ||
| 51 | 35213 | @Override |
| 52 | public ResourceType resolve(String type, Map<String, Object> parameters) | |
| 53 | throws CreateResourceTypeException | |
| 54 | { | |
| 55 | 35222 | if (type.equals(this.configuration.getEntityPathPrefix())) { |
| 56 | 28626 | return EntityResourceReference.TYPE; |
| 57 | } else { | |
| 58 | 6593 | return new ResourceType(type); |
| 59 | } | |
| 60 | } | |
| 61 | } |