1 /* 2 * Copyright 2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.resteasy.hypermedia.resources; 17 18 import javax.ws.rs.core.UriInfo; 19 20 import de.smartics.resteasy.hypermedia.adapter.DiscoveredResourceRepository; 21 import de.smartics.resteasy.hypermedia.adapter.RestEasyResourceDiscovery; 22 23 /** 24 * The discovery service for resources. 25 */ 26 public final class ResourceDiscovery 27 { 28 // ********************************* Fields ********************************* 29 30 // --- constants ------------------------------------------------------------ 31 32 // --- members -------------------------------------------------------------- 33 34 // ****************************** Initializer ******************************* 35 36 // ****************************** Constructors ****************************** 37 38 private ResourceDiscovery() 39 { 40 } 41 42 // ****************************** Inner Classes ***************************** 43 44 // ********************************* Methods ******************************** 45 46 // --- init ----------------------------------------------------------------- 47 48 // --- get&set -------------------------------------------------------------- 49 50 /** 51 * Returns the flag that controls whether (<code>true</code>) or not ( 52 * <code>false</code>) encoded slashes in the URL paths should be unencoded. 53 * 54 * @return the value of the flag. 55 */ 56 public static boolean isUnencodeSlashInPath() 57 { 58 return RestEasyResourceDiscovery.isUnencodeSlashInPath(); 59 } 60 61 /** 62 * Sets the flag that controls whether (<code>true</code>) or not ( 63 * <code>false</code>) encoded slashes in the URL paths should be unencoded. 64 * 65 * @param unencodeSlashInPath the value of the flag. 66 * @impl <code>org.jboss.resteasy.links.impl.RESTUtils</code> does not allow 67 * to control the encoding of slashes. This method allows to unencode 68 * every URL discovered. Simply <code>%2F</code> are replaced. 69 */ 70 public static void setUnencodeSlashInPath(final boolean unencodeSlashInPath) 71 { 72 RestEasyResourceDiscovery.setUnencodeSlashInPath(unencodeSlashInPath); 73 } 74 75 // --- business ------------------------------------------------------------- 76 77 /** 78 * Calculates the service discovery. 79 * 80 * @param entity the resource to analyze for link information. 81 * @param uriInfo the helper to construct links. 82 * @return the service discovery. 83 */ 84 public static Resources createDiscovery(final Object entity, 85 final UriInfo uriInfo) 86 { 87 return RestEasyResourceDiscovery.createDiscovery(entity, uriInfo); 88 } 89 90 /** 91 * Returns an empty resource collection. 92 * 93 * @return an empty resource collection. 94 */ 95 public static Resources createDiscovery() 96 { 97 final Resources resources = new DiscoveredResourceRepository(); 98 return resources; 99 } 100 101 // --- object basics -------------------------------------------------------- 102 103 }